稻草网

  1. 首页
  2. 技术
  3. Webpack
  4. 正文

新版Webpack不允许直接使用插件的问题

2017年3月29日 4561点热度 1人点赞 0条评论

错误提示如下:

 For loader options: webpack 2 no longer allows custom properties in configuration.
     Loaders should be updated to allow passing options via loader options in module.rules.
     Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:
     plugins: [
       new webpack.LoaderOptionsPlugin({
         // test: /\.xxx$/, // may apply this only for some modules
         options: {
           postcss: ...
         }
       })
     ]

也就是说,Webpack 2.1.0-beta23之后的版本,不能直接包含自定义配置项,如下:

 postcss: [
    require('autoprefixer')
  ],

必须要使用下面这样的方式

 plugins: [
        new webpack.LoaderOptionsPlugin({
            options: {
                postcss: [
                    require('autoprefixer')//调用autoprefixer插件
                ]               
            }
        })      
    ]

 

标签: plugins Webpack
最后更新:2017年6月8日

何 同学

这个人很懒,什么都没留下

点赞
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

COPYRIGHT © 2025 稻草网. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang