Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

compilation.getLogger is not a function

I upgraded copy-webpack-plugin from 4.6.0 to 6.0.2

and I changed my code from

plugins: [
    new CopyWebpackPlugin([{
      from: clientAssetPath,
      to: paths.STATICS,
      ignore: [ '.gitkeep' ],
    }], {
      debug: 'info'
    }),
    new HtmlWebpackPlugin({
      ...htmlPluginOptions,
    }),
    new DynamicCDNWebpackPlugin({
      resolver: unpkgResolver,
    }),
  ]

to

plugins: [
    new CopyPlugin([{
      patterns: [{
        from: clientAssetPath,
        to: paths.STATICS,
        noErrorOnMissing: true
      }]
    }]),
    new HtmlWebpackPlugin({
      ...htmlPluginOptions,
    }),
    new DynamicCDNWebpackPlugin({
      resolver: unpkgResolver,
    }),
  ]

as given on official website

But it started throwing following error: compilation.getLogger is not a function

When I debugged it I found error is coming from node_modules/copy-webpack-plugin/dist/index.js enter image description here don't know what is the problem

like image 492
Akhilesh Kumar Avatar asked Dec 08 '22 10:12

Akhilesh Kumar


1 Answers

It needs upgrade of webpack as well https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/package.json#L41

I could be able to fix the problem in following two ways

  1. downgrading copy-webpack-plugin to 5.1.1 and using the old constructor fixes the issue for me.
  2. Upgrading web-pack and resolve other syntax changes, caused by it
like image 146
Akhilesh Kumar Avatar answered Dec 10 '22 10:12

Akhilesh Kumar