F
F
Fanzoo2020-10-28 12:34:00
npm
Fanzoo, 2020-10-28 12:34:00

Why can't I connect the copy webpack plugin correctly?

After connecting the copy-webpack-plugin plugin, I can't import it normally.
5f99385bf0099787195021.png
What causes errors when building the project:

spoiler

[webpack-cli] ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
 - options[0] misses the property 'patterns'. Should be:
   [non-empty string | object { from, to?, context?, globOptions?, filter?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)
    at validate (/home/an/WebstormProjects/Excel-course/node_modules/schema-utils/dist/validate.js:104:11)
    at new CopyPlugin (/home/an/WebstormProjects/Excel-course/node_modules/copy-webpack-plugin/dist/index.js:54:31)
    at Object.<anonymous> (/home/an/WebstormProjects/Excel-course/webpack.config.js:19:5)
    at Module._compile (/home/an/WebstormProjects/Excel-course/node_modules/v8-compile-cache/v8-compile-cache.js:194:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (/home/an/WebstormProjects/Excel-course/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at requireConfig (/home/an/WebstormProjects/Excel-course/node_modules/webpack-cli/lib/groups/ConfigGroup.js:73:18) {
  errors: [
    {
      keyword: 'required',
      dataPath: '[0]',
      schemaPath: '#/required',
      params: [Object],
      message: "should have required property 'patterns'",
      schema: [Object],
      parentSchema: [Object],
      data: [Object],
      children: [Array]
    }
  ],
  schema: {
    definitions: { ObjectPattern: [Object], StringPattern: [Object] },
    type: 'object',
    additionalProperties: false,
    properties: { patterns: [Object], options: [Object] },
    required: [ 'patterns' ]
  },
  headerName: 'Copy Plugin',
  baseDataPath: 'options',
  postFormatter: null
}



There were no solutions in the official documentation.
Maybe someone faced such a problem? Please help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2020-10-28
@Fanzoo

How is it that there were no solutions in the official documentation?
Take a closer look - https://webpack.js.org/plugins/copy-webpack-plugin/
and the error clearly says: message: "should have required property 'patterns'",
schema: {
definitions: { ObjectPattern: [ Object], StringPattern: [Object] },
type: 'object',
additionalProperties: false,
properties : { patterns : [Object], options : [Object] },
required: [ 'patterns' ]
},

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question