webpack+Terser 代码压缩
// webpack.config.js
const TerserPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
module.exports = {optimization: {// 是否要启用压缩,默认情况下,生产环境会自动开启minimize: true, minimizer: [ // 压缩时使用的插件,可以有多个new TerserPlugin(), new OptimizeCSSAssetsPlugin()],},
};