为什么加了exclude之后就报了很多错误呢?

来源:4-2 使用 babel-loader 转换 ES6 代码(上)

不完美

2017-07-03 17:32

为什么加了exclude之后就报了很多错误呢? 这样写: exclude:__dirname+'/node_modules/', 这样写:  exclude:'./node_modules/', 这样写:  exclude:__dirname+/node_modules/, 这样写:  exclude:/node_modules/, 都不行 错误如下:

Invalid configuration object. Webpack has been initialised using a configur

 object that does not match the API schema.

 - configuration.module.rules[0].use should be one of these:

   non-empty string | function | object { loader?, options?, query? } | fun

 | [non-empty string | function | object { loader?, options?, query? }]

   Details:

    * configuration.module.rules[0].use should be a string.

    * configuration.module.rules[0].use should be an instance of function.

    * configuration.module.rules[0].use has an unknown property 'exclude'.

 properties are valid:

      object { loader?, options?, query? }

    * configuration.module.rules[0].use has an unknown property 'include'.

 properties are valid:

      object { loader?, options?, query? }

    * configuration.module.rules[0].use should be one of these:

      non-empty string | function | object { loader?, options?, query? }

    * configuration.module.rules[0].use should be an instance of function.

    * configuration.module.rules[0].use should be an array:

      [non-empty string | function | object { loader?, options?, query? }]


写回答 关注

5回答

  • 慕UI8191180
    2021-12-05 14:42:18

    把exclude配置再option目录下面,可不配置绝对路径

  • 你丫xiao笨熊
    2017-09-17 16:56:21

    使用绝对路径

  • 十亿燚
    2017-09-11 17:03:50

    exclude: __dirname +'./node_modules/'

  • 黑炎岚月
    2017-07-14 10:05:10

    错哪里了

  • 不完美
    2017-07-03 17:39:10

    好吧,知道错哪里了

webpack深入与实战

webpack实战教程,用真实项目带你探索 webpack 强大的功能

86558 学习 · 721 问题

查看课程

相似问题