解决vue3压缩打包 Cannot read property ‘thisCompilation’ of undefined异常

最近电脑环境重新整顿一下打生产包发现一直异常:

/Users/xxxx/app-class-h5/node_modules/compression-webpack-plugin/dist/index.js:413
    compiler.hooks.thisCompilation.tap(pluginName, compilation => {
                   ^

TypeError: Cannot read property 'thisCompilation' of undefined
    at CompressionPlugin.apply (/Users/xxxx/app-class-h5/node_modules/compression-webpack-plugin/dist/index.js:413:20)
    at Compiler.apply (/Users/xxxx/app-class-h5/node_modules/tapable/lib/Tapable.js:375:16)
    at webpack (/Users/xxxx/app-class-h5/node_modules/webpack/lib/webpack.js:33:19)
    at /Users/fplei/xxxx/app-class-h5/build/build.js:19:3
    at next (/Users/xxxx/app-class-h5/node_modules/rimraf/rimraf.js:83:7)
    at CB (/Users/xxxx/app-class-h5/node_modules/rimraf/rimraf.js:119:9)
    at /Users/xxxx/app-class-h5/node_modules/rimraf/rimraf.js:145:14

原因:版本不统一
解决:

compression-webpack-plugin (版本:1.1.12)
1- npm install –save-dev compression-webpack-plugin @1.1.12

extract-text-webpack-plugin (版本:3.0.0)
2- npm install –save-dev compression-webpack-plugin @3.0.0

copy-webpack-plugin(版本:4.0.1)
npm install –save-dev copy-webpack-plugin @4.0.1

注意,上述包如果有版本问题,请先使用 npm uninstall xxx 进行卸载再重新安装即可。