1.壓縮JS代碼,mode設置為production后,打包時自動壓縮代碼
mode:'production',
2.壓縮html文件,html文件不需要處理兼容問題,壓縮文件只需要在plugins中的HtmlWebpackPlugin中配置minify即可
new HtmlWebpackPlugin({ template:'./src/index.html', minify:{ //移除空格 collapseWhitespace:true, //移除注釋 removeComments:true }, }),