vue.config.js中chainWebpack配置问题

weixin_38078293 2019-03-11 09:07:09
使用@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)
...全文
1391 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38086437 2019-07-15
  • 打赏
  • 举报
回复
QQ图片20190715105828.png808×575 43.5 KB 这样应该是加成功了吧,还是报错 image.png1350×496 138 KB
weixin_38088241 2019-07-11
  • 打赏
  • 举报
回复
请问这个问题解决了吗
weixin_38093364 2019-03-14
  • 打赏
  • 举报
回复
vue inspect 看一下你编辑的 Webpack 配置是否正常。

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧