1.terser-webpack-plugin
js压缩插件,当其他js压缩插件没用时可以考虑
https://www.npmjs.com/package/terser-webpack-plugin
https://github.com/webpack-contrib/terser-webpack-plugin
webpack.config.js
const TerserPlugin = require('terser-webpack-plugin'); module.exports = { optimization: { minimize: true, minimizer: [new TerserPlugin()], }, };
深入了解terser插件请查看文档
2. uglifyjs-webpack-plugin
因为uglifyjs不支持es6语法,所以用terser-webpack-plugin替代uglifyjs-webpack-plugin
3. webpack-parallel-uglify-plugin