解决 Copy Plugin版本问题 (麻烦老师看下是否有问题)
来源:11-3 Webpack配置优化
THEEND0123
2020-11-17
我的版本 =>
"copy-webpack-plugin": "^6.3.1",
运行
npx webpack
报错 =>
[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 (H:\ld\task\code\Webpack\02\node_modules\schema-utils\dist\validate.js:104:11)
at new CopyPlugin (H:\ld\task\code\Webpack\02\node_modules\copy-webpack-plugin\dist\index.js:54:31)
at Object.<anonymous> (H:\ld\task\code\Webpack\02\webpack.config.js:14:9)
at Module._compile (H:\ld\task\code\Webpack\02\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
at Module.load (internal/modules/cjs/loader.js:982:32)
at Function.Module._load (internal/modules/cjs/loader.js:875:14)
at Module.require (internal/modules/cjs/loader.js:1022:19)
at require (H:\ld\task\code\Webpack\02\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at requireConfig (H:\ld\task\code\Webpack\02\node_modules\webpack-cli\lib\groups\resolveConfig.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
}
new CopyPlugin({
patterns: [
{ from: "static", to: "static" }
],
})
写回答
1回答
-
谢成
2020-11-18
可以,建议多参考下webpack文档。
00
相似问题