compilation.getLogger is not a function
Asked Answered
O

1

5

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

Onofredo answered 22/6, 2020 at 16:32 Comment(0)
O
15

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
Onofredo answered 22/6, 2020 at 16:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.