npm run build: ValidationError: Invalid options object. Copy Plugin

npm run build: ValidationError: Invalid options object. Copy Plugin

我正在尝试打包 Electron 应用程序,但出现此错误:

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?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)
    at validate (C:\Users\julis\Documents\prescription-data-entry-system\pdes\node_modules\copy-webpack-plugin\node_modules\schema-utils\dist\validate.js:96:11)
    at new CopyPlugin (C:\Users\julis\Documents\prescription-data-entry-system\pdes\node_modules\copy-webpack-plugin\dist\index.js:24:30)
    at Object.<anonymous> (C:\Users\julis\Documents\prescription-data-entry-system\pdes\.electron-vue\webpack.renderer.config.js:181:5)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (C:\Users\julis\Documents\prescription-data-entry-system\pdes\.electron-vue\build.js:14:24)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47 {
  name: 'ValidationError',
  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,
  message: 'Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.\n' +
    " - options[0] misses the property 'patterns'. Should be:\n" +
    '   [non-empty string | object { from, to?, context?, globOptions?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)'
}

.electron-vue\webpack.renderer.config.js中,我有:

new CopyWebpackPlugin([
  {
    from: path.join(__dirname, '../static'),
    to: path.join(__dirname, '../dist/electron/static'),
    ignore: ['.*']
  }
]),

并将其更改为以下内容并没有解决错误:

    new CopyWebpackPlugin({

      patterns: [
        { from: path.join(__dirname, '../static'), to: path.join(__dirname, '../dist/electron/static') },
      ],

    }),

我不确定新模式应该是什么。我查看了 this question 并尝试遵循该模式,但没有奏效。我怎样才能解决这个问题?

我不得不在 .electron-vue\webpack.web.config.js

中更改相同的内容
/**
 * Adjust webConfig for production settings
 */
if (process.env.NODE_ENV === 'production') {
  webConfig.devtool = ''

  webConfig.plugins.push(
    new MinifyPlugin(),
    new CopyWebpackPlugin({
      //this is the new change
      patterns: [
        { from: path.join(__dirname, '../static'), to: path.join(__dirname, '../dist/electron/static') },
      ],

    }),
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': '"production"'
    }),
    new webpack.LoaderOptionsPlugin({
      minimize: true
    })
  )
}