const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
module.exports = {
optimization: {
minimizer: [new UglifyJsPlugin()],
}
///
plugins : [
new webpack.optimize.UglifyJsPlugin({
mangle: true,
compress: {
warnings: false, // Suppress uglification warnings
pure_getters: true,
unsafe: true,
unsafe_comps: true,
screw_ie8: true
},
output: {
comments: false,
},
exclude: [/\.min\.js$/gi] // skip pre-minified libs
}),
// ...
我的捆绑包大小为8.6 Mb。我需要将其大小调整为1-3 Mb。如果我的插件给我一个错误Unresolved type UglifyJsPlugin
,我该怎么办?
答案 0 :(得分:0)
您不应将其用作插件:plugins : [new webpack.optimize.UglifyJsPlugin({
您还使用了错误的结构。根据{{3}},您的选择应如下所示:
module.exports = {
optimization: {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
mangle: true,
warnings: false,
compress: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
//screw_ie8: true, // no such option in uglify
},
output: {
comments: false,
},
},
exclude: [/\.min\.js$/gi] // skip pre-minified libs
}),
],
},
};