Vue 配置多个 html 文件



默认情况下,Vue 将构建src/main.js并将构建脚本注入public/index.html

有没有办法支持多个html文件?

示例:我有public/index.htmlpublic/not-support.html,每个 html 还有 2 个脚本文件,src/main.js个脚本文件,src/not-support.js个脚本文件用于public/not-support.html

构建后,我们将注入单独的脚本文件的dist/index.htmldist/not-support.html

如果你使用 vue-cli,你可以在 vue.config.js 文件中设置 config 以支持多个 HTML 文件:

const config = {
devServer: {
open: true,
disableHostCheck: true,
},
pages: {
index: {
entry: 'src/index.js',
template: 'public/index.html',
filename: 'index.html',
},
support: {
entry: 'src/support.js',
template: 'public/support.html',
filename: 'support.html',
},
},
// ...config code
}
module.exports = config

请参阅链接,在多页模式下构建应用

谢谢。

最新更新