JS代码压缩
内置了uglifyjs-webpack-plugin
CSS文件的压缩
- 使用
optimize-css-assets-webpack-plugin,同时使用cssnano(webpack4)
1 | module.exports = { |

- 使用
css-minimizer-webpack-plugin,1
2
3
4
5
6
7
8
9
10
11module.exports = {
// ...
optimization: {
minimize: false, // If you want to run it also in development set the optimization.minimize option to true
minimizer: [
// For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
// `...`,
new CssMinimizerPlugin(),
],
},
}
HTML文件的压缩
修改html-webpack-plugin,设置压缩参数
1 | module.exports = { |