Error compressing packaged resources with WEBPACK

/ / package file
if (config.build.outputZip) {
var ZipPlugin=require ("zip-webpack-plugin")
webpackConfig.plugins.push (

)
new ZipPlugin({
  path:config.build.assetsRoot,
  filename:"output.zip"
})

)

}

error message

compiler.hooks.emit.tapAsync(ZipPlugin.name, function(compilation, callback) {
               ^

TypeError: Cannot read property "emit" of undefined

Mar.17,2021

this problem is caused by the high version of webpack-zip-plugin. I don't know which plug-in is incompatible with it. I can use version 2.0.0


this plugin has not been used, so it is recommended that you use this plugin webpack-zip-plugin. I have no problem with this.

var WebpackZipPlugin = require('webpack-zip-plugin');

        plugins.push(new WebpackZipPlugin({
            initialFile: `build/${subPath}/`,  // (dist)
            endPath: `build/zip/`,  // './'
            zipName: `${srcPath}_${versionWithoutTime}` // 
        }));

how to solve the problem?

Menu