webpack压缩代码组件uglifyjs-webpack-plugin

时间:2024-03-18 09:19:48

package.json配置

"webpack": "3.10.0",
"uglifyjs-webpack-plugin": "^1.3.0",

webpack.config.js配置

const UglifyJsPlugin = require(\'uglifyjs-webpack-plugin\');
 
组件加载
config.plugins.push(
        new UglifyJsPlugin({
            parallel: 4,
            uglifyOptions: {
                output: {
                comments: false,
                beautify: false,
                },
                compress: {
                warnings: false
                },
            },
            cache: true,
        }),  
);