注意的是需要 new 两个 HtmlWebpackPlugin()
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
//多入口
mode: 'production',
entry: {
home: './src/index.js',
other: './src/other.js'
},
output: {
// [name] 表示 home 和 other
filename: '[name].js',
path: path.join(__dirname, './dist')
},
plugins: [
new HtmlWebpackPlugin({
template: 'index.html',
filename: 'home.html',
chunks:['home']
}),
new HtmlWebpackPlugin({
template: 'index.html',
filename: 'other.html',
chunks:['other']
}),
],
}