1 回答

TA貢獻1793條經驗 獲得超6個贊
module.exports = {
? entry: {
? ? index: './src/index.js'
? },
? // ...
? plugins: [
? ? new HtmlWebpackPlugin({
? ? ? ? template: './src/index.html',
? ? ? ? inject: true,
? ? ? ? chunks: ['index'],
? ? ? ? filename: 'index.html'
? ? }),
? ]
};
上面我們index.js在每個頁面中重用文件chunks: [‘index’]來更改此設置,只需添加新的Javascript文件about.js contacts.js,然后在條目配置中使用這些文件并在配置選項中引用它 HtmlWebpackPlugin:
//...
entry: {
? ? index: './src/index.js',
? ? about: './src/about.js',?
? ? contacts: './src/contacts.js'
},
//...
plugins: [
? new HtmlWebpackPlugin({
? ? ? template: './src/about.html',
? ? ? inject: true,
? ? ? chunks: ['about'],
? ? ? filename: 'about.html'
? }),
所以你需要在entry使用的塊中聲明plugins。
添加回答
舉報