自动产出html
我们希望自动能产出HTML文件,并在里面引入产出后的资源。
1. html-webpack-plugin
new HtmlWebpackPlugin({
template:'./public/index.html',//选择模板
filename:'index.html'//产出后的文件名
hash:true//为了避免缓存,可以在产出的资源后面添加hash值
chunks:['index','login'],//引入的chunk文件(webpack打包后生成的js文件)
chunksSortMode:'manual',//按chunks数组的顺序引入js文件,从左到右
minify:{
//压缩
removeAttributeQuotes:true,
collapseWhitespace:true
}
})