Cannot read property 'tapPromise' of undefined when build using css-minimizer-webpack-plugin

webpack.common.js

optimization: {
  minimize: true, 
  minimizer: [
    new CssMinimizerPlugin({
      test: /\.foo\.css$/i,
      //or already used
      test: /\.css(\?.*)?$/i
    }),
  ],
},

any suggestion what the problem is?

Upvotes: 0

Views: 3590

Answers (1)

Mary
Mary

Reputation: 165

This error is probably referring to

compilation.hooks.processAssets.tapPromise

You can use processAssets hook with Webpack versions higher than 5. css-minimizer-webpack-plugin migrated on processAssets hook since version 1.1.0.

Basically, there are two options to resolve this issue:

  • to lower version of css-minimizer-webpack-plugin to 1.0.0

     npm uninstall css-minimizer-webpack-plugin
    
     npm install [email protected]
    

or

  • to upgrade webpack to higher than 5. If you're choosing this option, you probably want to research migration docs.

Upvotes: 2

Related Questions