-1

I've upgraded dependencies in my application. In particular webpack from 4.43 to 5.88, related dependencies are also updated:

Now, I see this error during yarn build.

    YN0000: [..]: Process started
    ➤ YN0000: [..]: Process started
    ➤ YN0000: [..]: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
    ➤ YN0000: [..]:  - options[0] has an unknown property 'to'. These properties are valid:
    ➤ YN0000: [..]:    object { patterns, options? }
    ➤ YN0000: [..]:  - options[1] has an unknown property 'to'. These properties are valid:
    ➤ YN0000: [..]:    object { patterns, options? }
    ➤ YN0000: [..]: ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.

and some following stack trace:

    ➤ YN0000: [..]:     at validate (%app%\node_modules\copy-webpack-plugin\node_modules\schema-utils\dist\validate.js:158:11)
    ➤ YN0000: [..]:     at new CopyPlugin (%app%\node_modules\copy-webpack-plugin\dist\index.js:172:5)
    ➤ YN0000: [..]:     at configure (%app%\innerproject\/webpack.config.babel.js:86:5)
    ➤ YN0000: [..]:     at _default (%app%\innerproject\/webpack.config.babel.js:131:31)
    ➤ YN0000: [..]:     at handleFunction (%app%\innerproject\node_modules\webpack-cli\bin\utils\prepareOptions.js:21:13)
    ➤ YN0000: [..]:     at prepareOptions (%app%\innerproject\node_modules\webpack-cli\bin\utils\prepareOptions.js:9:5)
    ➤ YN0000: [..]:     at requireConfig (%app%\innerproject\node_modules\webpack-cli\bin\utils\convert-argv.js:117:14)
    ➤ YN0000: [..]:     at %app%\innerproject\node_modules\webpack-cli\bin\utils\convert-argv.js:123:17
    ➤ YN0000: [..]:     at Array.forEach (<anonymous>)
...

This is what I have in webpack.config.babel.js (line 86):

plugins: [
..
  new CopyWebpackPlugin([
    { from: 'src/data', to: 'data' },
    { from: 'src/images', to: 'images' }
  ]),
..
]

it looks like to argument is no longer supported, where can I find a new format?

UPDATE:

when I use a newer format:

new CopyWebpackPlugin(
{
  patterns: [
    { from: 'src/data', to: 'data' },
    { from: 'src/images', to: 'images' }
]}),

I see a different error:

        YN0000: [..]: %app%\innerproject\node_modules\webpack-cli\bin\cli.js:281
        ➤ YN0000: [..]:                               throw err;
        ➤ YN0000: [..]:                               ^
        ➤ YN0000: [..]:
        ➤ YN0000: [..]: TypeError: Cannot read properties of undefined (reading 'tap')
        ➤ YN0000: [..]:     at HtmlWebpackPlugin.apply (%app%\node_modules\html-webpack-plugin\index.js:40:31)
        ➤ YN0000: [..]:     at webpack (%app%\innerproject\node_modules\webpack\lib\webpack.js:51:13)
        ➤ YN0000: [..]:     at processOptions (%app%\innerproject\node_modules\webpack-cli\bin\cli.js:272:16)
        ➤ YN0000: [..]:     at %app%\innerproject\node_modules\webpack-cli\bin\cli.js:364:3

webpack cli I use is "webpack-cli": "^5.1.4"

Unnamed
  • 111
  • 8

1 Answers1

1

You can find the latest config example on the NPM page or on the README:

new CopyWebpackPlugin({
    patterns: [
        { from: 'src/data', to: 'data' },
        { from: 'src/images', to: 'images' }
    ],
}),
Vivick
  • 3,434
  • 2
  • 12
  • 25