126.使用同一模板文件生成不同文件且標題不同,修改webpack.config.js文件,代碼如下
var htmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
entry:{
main:'./src/script/main.js',
a:'./src/script/a.js'
},
output:{
path:'./dist',
filename:'js/[name]-[hash].js',
},
plugins:[
new htmlWebpackPlugin({
template:'index.html',
filename:'a.html',
inject:false,
title:'this is a.html'
}),
new htmlWebpackPlugin({
template:'index.html',
filename:'b.html',
inject:false,
title:'this is b.html'
}),
new htmlWebpackPlugin({
template:'index.html',
filename:'c.html',
inject:false,
title:'this is c.html'
})
]
}
127.修改模板文件index.html,代碼如下
128.使用cnpm run webpack命令重新打包
129.查看生成的a.html,b.html,c.html文件