vue.config.js中chainWebpack配置问题
使用@vue/cli 3.4、3.5新建的工程,想在工程目录下添加一个目录作为组件库目录,但在在vue.config.js中添加目录报错误:
vue.config.js:
module.exports = {
// 扩展 webpack 配置,使 packages 加入编译
chainWebpack: config => {
config.module
.rule(‘js’)
.include
.add(‘packages’)
.end()
.use(‘babel’)
.loader(‘babel-loader’)
.tap(options => {
return options
})
}
}
error:
INFO Starting development server…
ERROR WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
configuration.module.rules[12].include should be one of these:
RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? } | [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
-> One or multiple rule conditions
Details:
configuration.module.rules[12].include should be an instance of RegExp
configuration.module.rules[12].include should be a string.
configuration.module.rules[12].include should be an instance of function
configuration.module.rules[12].include[0] should be an instance of RegExp
configuration.module.rules[12].include[0]: The provided value “packages” is not an absolute path!
configuration.module.rules[12].include[0] should be an instance of function
configuration.module.rules[12].include[0] should be an array:
[RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
configuration.module.rules[12].include[0] should be an object.
configuration.module.rules[12].include should be an object.
configuration.module.rules[12].include[0] should be an instance of RegExp
configuration.module.rules[12].include[0]: The provided value “packages” is not an absolute path!
configuration.module.rules[12].include[0] should be an instance of function
configuration.module.rules[12].include[0] should be an array:
[RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
configuration.module.rules[12].include[0] should be an object.
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
configuration.module.rules[12].include should be one of these:
RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? } | [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
-> One or multiple rule conditions
Details:
configuration.module.rules[12].include should be an instance of RegExp
configuration.module.rules[12].include should be a string.
configuration.module.rules[12].include should be an instance of function
configuration.module.rules[12].include[0] should be an instance of RegExp
configuration.module.rules[12].include[0]: The provided value “packages” is not an absolute path!
configuration.module.rules[12].include[0] should be an instance of function
configuration.module.rules[12].include[0] should be an array:
[RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
configuration.module.rules[12].include[0] should be an object.
configuration.module.rules[12].include should be an object.
configuration.module.rules[12].include[0] should be an instance of RegExp
configuration.module.rules[12].include[0]: The provided value “packages” is not an absolute path!
configuration.module.rules[12].include[0] should be an instance of function
configuration.module.rules[12].include[0] should be an array:
[RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
configuration.module.rules[12].include[0] should be an object.
at webpack (/Volumes/Works/Projects/Work2019/czpsla/fvue/node_modules/webpack/lib/webpack.js:31:9)
at serve (/Volumes/Works/Projects/Work2019/czpsla/fvue/node_modules/@vue/cli-service/lib/commands/serve.js:134:22)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:757:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)