webpack 之压缩js代码 和html文件
1.压缩JS代码,mode设置为production后,打包时自动压缩代码
mode:\'production\',
2.压缩html文件,html文件不需要处理兼容问题,压缩文件只需要在plugins中的HtmlWebpackPlugin中配置minify即可
new HtmlWebpackPlugin({ template:\'./src/index.html\', minify:{ //移除空格 collapseWhitespace:true, //移除注释 removeComments:true }, }),