打包多页应用
webpack.config.js
let path = require('path');
let HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
// 多入口
mode: 'development',
entry: {
home: './src/index.js',
other: './src/other.js'
},
output: {
// 这里的 name代表 home, other
filename: '[name]bundle.js',
path: path.resolve(__dirname, 'dist')
},
plugins: [
new HtmlWebpackPlugin({
template: "./index.html",
filename: "home.html",
chunks: [
"home",
],
}),
new HtmlWebpackPlugin({
template: "./index.html",
filename: "other.html",
chunks: ["home", "other"],
})
]
};