What problem does this feature solve?
vue-cli 3.0 怎么配置多页面 ( How to configure multiple pages on vue-cli 3.0 )?
What does the proposed API look like?
Typescript + 多页面配置
Hello, your issue has been closed because it does not conform to our issue requirements. In order to ensure every issue provides the necessary information for us to investigate, we require the use of the Issue Helper when creating new issues. Thank you!
你好,你的 issue 不符合我们所要求的格式,因此已被自动关闭。为了确保每个 issue 都提供必需的相关信息,请务必使用我们的 Issue 向导 来创建新 issue,谢谢!
我也在找这个多页面的配置方法,然而并没有找到,于是自己摸索出来了。只需要修改vue.config.js文件即可,修改后文件内容如下:
// vue.config.js
const HtmlWebpackPlugin = require('html-webpack-plugin')
var pageNames = ['custom', 'origin']
var entry = {}
var plugins = []
pageNames.map(pageName => {
entry[pageName] = ./src/${pageName}.js
// js文件路径
plugins.push(new HtmlWebpackPlugin({
filename: pageName + '.html',
template: ./public/${pageName}.html
, //模板路径
inject: true,
excludeChunks: pageNames.filter(item => item != pageName)
}))
})
module.exports = {
lintOnSave: true,
configureWebpack: {
entry,
plugins
},
chainWebpack: config => {
config.entry('app').clear().end()
}
}
希望对你有所帮助
Should this work with historyApiFallback or am I doing something wrong?
@giggo1604 Have you solved it ?
@itxuye Nope, currently working with an "vue project per site" setup (I only have two sites) and share common components via a symlinked local npm module. This is not very satisfying but i didn't have the time to further dig into vue-cli-3 and make it work...
Got it working, only tested it in dev mode... https://gist.github.com/giggo1604/7eee28f4f8b56ff359bde4cadf6c3f43
additionally the base has to be set in the template files like <base href="/foo/">
Most helpful comment
https://cli.vuejs.org/config/#pages