webpack關于通過html-webpack-plugin插件使用同一個模版template生成多個文件
plugins:[
????new htmlWebpackPlugin({
????????????template:'index.html',
????????????filename:'index.a.html',
????????????inject:false,
????????????title:'webpack title a',
????????????body:'a body',
????????????excludeChunks:['b','c']
????????????minify:{
????????????removeComments:true, ?//去除注釋
????????????collapseWhitespace:true ?//去除空格
????}
})
用一個模版生成一個index.a.html文件,沒問題,但是用同一個模版生成index.a.html,index.b.html,index.c.html就會報錯,視頻里老師也沒錯啊,而且報錯有點莫名其妙,有和我一樣的么?
用兩個不同的模版生成兩個文件也沒問題
????plugins:[
????????new htmlWebpackPlugin({
????????template:'index.html',
????????filename:'index.a.html',
????????inject:false,
? ? ????title:'webpack title a',
????????body:'a body',
????????excludeChunks:['b','c']
????????minify:{
????????????removeComments:true, ?//去除注釋
????????????collapseWhitespace:true ?//去除空格
????????}
????}),
????new htmlWebpackPlugin({
????????template:'index.html',
????????filename:'index.b.html',
????????inject:false,
????????title:'webpack title b',
????????body:'b body',
????????chunks:['main','b']
????}),
????new htmlWebpackPlugin({
????????template:'index.html',
????????filename:'index.c.html',
????????inject:false,
????????title:'webpack title c',
????????body:'c body',
????????chunks:['main','c']
????})
]
2017-07-27
模板文件的script引用刪除了么? 注釋掉是不行的,必須要刪除