观察忽略插件已使用不符合API模式的选项对象进行初始化。

4
Webpack: Starting ...
ui/node_modules/schema-utils/dist/validate.js:104
    throw new _ValidationError.default(errors, schema, configuration);
    ^

ValidationError: Invalid options object. Watch Ignore Plugin has been initialized using an options object that does not match the API schema. {
  schema: {
    title: 'WatchIgnorePluginOptions',
    type: 'object',
    additionalProperties: false,
    properties: {
      paths: {
        description: 'A list of RegExps or absolute paths to directories or files that should be ignored.',
        type: 'array',
        items: {
          description: 'RegExp or absolute path to directories or files that should be ignored.',
          anyOf: [ [Object], [Object] ]
        },
        minItems: 1
      }
    },
    required: [ 'paths' ]
  },
  headerName: 'Watch Ignore Plugin',
  baseDataPath: 'options',
  postFormatter: null
}

它使用以下配置进行投掷:

new webpack.WatchIgnorePlugin([ 'src/test' ])

webpack的版本是"^5.0.0-rc.6"。根据构造函数提示

constructor(paths: Array<string | RegExp>)

"

[ 'src/test' ] 应该没问题。 我在哪里犯了错?

"
1个回答

12

我从这个问题中得到了答案。

WatchIgnorePlugin选项应该被转换为:

new webpack.WatchIgnorePlugin({paths: [ 'src/test' ]})

当从js调用new webpack.WatchIgnorePlugin({paths: [ 'src/test' ]})时,如何解决以下警告:参数类型{paths:[string]}不可分配给参数类型Array<string | RegExp> - NameAlex

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接