0

I'm running a nextJS Project with 'yarn dev' and the following error is shown:

`ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.`

- options.patterns should be a non-empty array.
  at validate (C:\\Users\\wsial\\Desktop\\walid\\GithubRepos\\automa-to\\dashboard\\node_modules\\copy-webpack-plugin\\node_modules\\schema-utils\\dist\\validate.js:115:11)
  at new CopyPlugin (C:\\Users\\wsial\\Desktop\\walid\\GithubRepos\\automa-to\\dashboard\\node_modules\\copy-webpack-plugin\\dist\\index.js:172:5)
  at Object.webpack (C:\\Users\\wsial\\Desktop\\walid\\GithubRepos\\automa-to\\dashboard\\next.config.js:96:7)
  at Object.webpack (C:\\Users\\wsial\\Desktop\\walid\\GithubRepos\\automa-to\\dashboard\\node_modules@next\\bundle-analyzer\\index.js:22:29)
  at Object.getBaseWebpackConfig \[as default\] (C:\\Users\\wsial\\Desktop\\walid\\GithubRepos\\automa-to\\dashboard\\node_modules\\next\\dist\\build\\webpack-config.js:1446:32)
  at async Promise.all (index 0)
  at async Span.traceAsyncFn (C:\\Users\\wsial\\Desktop\\walid\\GithubRepos\\automa-to\\dashboard\\node_modules\\next\\dist\\trace\\trace.js:79:20)
  at async Span.traceAsyncFn (C:\\Users\\wsial\\Desktop\\walid\\GithubRepos\\automa-to\\dashboard\\node_modules\\next\\dist\\trace\\trace.js:79:20)
  at async HotReloader.start (C:\\Users\\wsial\\Desktop\\walid\\GithubRepos\\automa-to\\dashboard\\node_modules\\next\\dist\\server\\dev\\hot-reloader.js:337:30)
  at async DevServer.prepare (C:\\Users\\wsial\\Desktop\\walid\\GithubRepos\\automa-to\\dashboard\\node_modules\\next\\dist\\server\\dev\\next-dev-server.js:528:9)
  at async C:\\Users\\wsial\\Desktop\\walid\\GithubRepos\\automa-to\\dashboard\\node_modules\\next\\dist\\cli\\next-dev.js:521:17 {
  errors: \[
  {
  \],
  schema: {
  definitions: { ObjectPattern: \[Object\], StringPattern: \[Object\] },
  type: 'object',
  additionalProperties: false,
  properties: { patterns: \[Object\], options: \[Object\] },
  required: \[ 'patterns' \]
  },
  headerName: 'Copy Plugin',
  baseDataPath: 'options',
  postFormatter: null
  }\`

Here is my next.config.js:

    config.plugins.push(
      new CopyWebpackPlugin({ patterns: themeConfig.copyConfig }),

      // Moment ships with a large number of locales. Exclude them, leaving
      // just the default English locale. If you need other locales, see:
      // https://create-react-app.dev/docs/troubleshooting/#momentjs-locales-are-missing
      new IgnorePlugin({
        resourceRegExp: /^\.\/locale$/,
        contextRegExp: /moment$/,
      })

CopyWebpackPlugin is responsible to copy theme css files into public directory. The patterns parameter contains an array of objects containing source paths that are going to be sent to the destination paths. The error returns that the array is empty. I tried to manually fill this array by copying paths from my collegue and still it is not working. When I uncomment the second line, the project is running perfectly but not with the appropriate css properties defined.

0 Answers0