我正在为我的苗条应用程序使用汇总。我将包rollup-plugin-serve
从 npm 安装给我们,historyApiFallback
这样我就可以在我的 spa 应用程序中提供任何 url。
https://github.com/thgh/rollup-plugin-serve
我的配置如下所示:
import serve from 'rollup-plugin-serve'
serve({
contentBase: 'dist',
port: 5000,
historyApiFallback: true,
historyApiFallback: 'index.html'
}),
这是我的完整rollup.config.js
import commonjs from 'rollup-plugin-commonjs';
import livereload from 'rollup-plugin-livereload';
import postcss from 'rollup-plugin-postcss';
import resolve from 'rollup-plugin-node-resolve';
import svelte from 'rollup-plugin-svelte';
import {terser} from 'rollup-plugin-terser';
import svelte_preprocess_postcss from 'svelte-preprocess-postcss';
import serve from 'rollup-plugin-serve'
const production = !process.env.ROLLUP_WATCH;
export default {
input: 'src/main.js',
output: {
format: 'iife',
sourcemap: true,
name: 'app',
file: 'dist/main.js',
},
plugins: [
svelte({
dev: !production,
preprocess: {
style: svelte_preprocess_postcss(),
},
css: css => {
css.write('dist/components.css');
},
}),
resolve(),
commonjs(),
postcss({
extract: true,
}),
serve({
contentBase: 'dist',
host: 'localhost',
port: 5000,
historyApiFallback: true
}),
!production && livereload('dist'),
production && terser(),
],
};
但是这段代码不起作用。当我发球时,localhost:5000/solutions/technic
我仍然收到 404 Not Found 错误。
有什么想法吗?