1、修改webpack.base.config.js
module.exports = {
context: path.resolve(__dirname, '../'),
//配置多页面应用
entry: {
app: './src/main.js',
one: './src/js/one.js',
},
...
}
2、修改webpack.dev.config.js, 在plugins中添加如下对象:
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true,
//与webpack.base.config.js那里的entry对应
chunks: ['app']
}),
new HtmlWebpackPlugin({
filename: 'one.html',
template: 'one.html',
inject: true,
chunks: ['one']
}),
3、修改config/index.js:
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
one: path.resolve(__dirname, '../dist/one.html'),
...
}
4、在项目路径下新增one.html