Closed camilleZJ closed 3 years ago
when I use it ,my project throw "TypeError: compiler.plugin is not a function"; Why?
const ParallelUglifyPlugin = require("webpack-parallel-uglify-plugin"); plugins: [ new ParallelUglifyPlugin({ uglifyJS: { output: { beautify: false, comments: false, }, compress: { warnings: false, drop_console: true, collapse_vars: true, reduce_vars: true, }, }, }), ],
const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin')
Plugins:
// 使用 ParallelUglifyPlugin 并行压缩输出的 JS 代码
new ParallelUglifyPlugin({
// 传递给 UglifyJS 的参数
// (还是使用 UglifyJS 压缩,只不过帮助开启了多进程)
uglifyJS: {
output: {
beautify: false, // 最紧凑的输出
comments: false, // 删除所有的注释
},
compress: {
// 删除所有的 console 语句,可以兼容 ie 浏览器
drop_console: true,
// 内嵌定义了但是只用到一次的变量
collapse_vars: true,
// 提取出出现多次但是没有定义成变量去引用的静态值
reduce_vars: true
}
}
})
There are some errors:
[webpack-cli] TypeError: compiler.plugin is not a function at FasterUglifyPlugin.apply (/Users/mac/JALProjects/iMooc-FEF/Webpack/node_modules/webpack-parallel-uglify-plugin/index.js:27:12) at createCompiler (/Users/mac/JALProjects/iMooc-FEF/Webpack/node_modules/webpack/lib/webpack.js:71:12) at create (/Users/mac/JALProjects/iMooc-FEF/Webpack/node_modules/webpack/lib/webpack.js:115:15) at webpack (/Users/mac/JALProjects/iMooc-FEF/Webpack/node_modules/webpack/lib/webpack.js:139:31) at f (/Users/mac/JALProjects/iMooc-FEF/Webpack/node_modules/webpack/lib/index.js:35:15) at WebpackCLI.createCompiler (/Users/mac/JALProjects/iMooc-FEF/Webpack/node_modules/webpack-cli/lib/webpack-cli.js:219:24) at WebpackCLI.run (/Users/mac/JALProjects/iMooc-FEF/Webpack/node_modules/webpack-cli/lib/webpack-cli.js:248:31) at async runCLI (/Users/mac/JALProjects/iMooc-FEF/Webpack/node_modules/webpack-cli/lib/bootstrap.js:76:24) error Command failed with exit code 2.
Webpack5 removes compiler.plugin. So I used webpack@4.44.2, that is ok.
The 2.0.0
release has been updated to work with webpack 5, webpack 3 will not work with 2.0.0
TypeError: compiler.plugin is not a function