5

copy-webpack-plugin从升级4.6.06.0.2

我改变了我的代码

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

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

正如官方网站上给出的

但它开始抛出以下错误: compilation.getLogger is not a function

当我调试它时,我发现错误来自node_modules/copy-webpack-plugin/dist/index.js 在此处输入图像描述 不知道是什么问题

4

1 回答 1

15

webpack它也需要升级https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/package.json#L41

我可以通过以下两种方式解决问题

  1. 降级copy-webpack-plugin到 5.1.1 并使用旧的构造函数为我解决了这个问题。
  2. 升级 web-pack 并解决由它引起的其他语法更改
于 2020-06-22T16:49:38.943 回答