webpact+react报错Invalid configuration object. Webpack has been initialised using a configuration obj

React系列学习笔记:1.React与webpack基本配置:https://www.jianshu.com/p/eb2da4fe7f5b   可参考目录分配,但是webpack.config.js配置中loaders写法已不能再使用。


会一直报无效的配置,如下:

F:\node.js\5-3\5-4>webpack

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

 - configuration.module has an unknown property 'loaders'. These properties are valid:

   object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, defaultRules?,

 unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCri

tical?, wrappedContextRecursive?, wrappedContextRegExp?, strictExportPresence?, strictThisContextOnImports? }

   -> Options affecting the normal modules (`NormalModuleFactory`).


原因 : webpack版本更新,新的规则改变。

解决:

把module里的那个loaders改成rules

1
2
3
4
5
6
7
8
module: {
  rules: [
         {
         test: /\.scss$/,
         loader: ( 'style!css!sass' )
         }
   ]
},
参考官方文档:

现在的webpack的loader是配置在rule里的

https://doc.webpack-china.org/configuration/module/#module-rules

猜你喜欢

转载自blog.csdn.net/hreticent/article/details/80489851
今日推荐