在React中设置Sass和CSS模块时的Webpack问题

时间:2018-12-13 14:27:29

标签: webpack sass css-modules

我的应用程序无法编译,当我尝试安装npm时,我看到以下内容:

npm WARN extract-text-webpack-plugin@3.0.2 requires a peer of webpack@^3.1.0 but none is installed. You must install peer dependencies yourself.

但是,只有当我将此插件添加到webpack.config.dev.js中时,这种情况才开始发生:

new ExtractTextPlugin({ filename: 'styles.css', allChunks: true }),

当我尝试运行我的应用程序时,我得到以下信息:

  

/Users/johnnynolan/Repos/clark-app/node_modules/webpack/lib/Chunk.js:824                   抛出新的错误(                   ^

     

错误:Chunk.entrypoints:使用Chunks.groupsIterable并按   代替EntryPoint的instanceof       在Chunk.get(/Users/johnnynolan/Repos/clark-app/node_modules/webpack/lib/Chunk.js:824:9)       在/Users/johnnynolan/Repos/clark-app/node_modules/extract-text-webpack-plugin/dist/index.js:176:48       在Array.forEach()       在/Users/johnnynolan/Repos/clark-app/node_modules/extract-text-webpack-plugin/dist/index.js:171:18       在AsyncSeriesHook.eval [作为callAsync](在创建(/Users/johnnynolan/Repos/clark-app/node_modules/tapable/lib/HookCodeFactory.js:32:10)时,   :7:1)       在AsyncSeriesHook.lazyCompileHook(/Users/johnnynolan/Repos/clark-app/node_modules/tapable/lib/Hook.js:154:20)       在Compilation.seal(/Users/johnnynolan/Repos/clark-app/node_modules/webpack/lib/Compilation.js:1214:27)       在hooks.make.callAsync.err(/Users/johnnynolan/Repos/clark-app/node_modules/webpack/lib/Compiler.js:547:17)       在_done(在创建时评估(/Users/johnnynolan/Repos/clark-app/node_modules/tapable/lib/HookCodeFactory.js:32:10),   :11:1)       在_err1上(在创建时为(/Users/johnnynolan/Repos/clark-app/node_modules/tapable/lib/HookCodeFactory.js:32:10),   :34:22)

1 个答案:

答案 0 :(得分:0)

my_plugin_render_block_latest_post()已过时。 取而代之的是,您可以使用ExtractTextPluginstyle-loadercss-loader,方法是将以下代码添加到Webpack中并安装所需的软件包。

postcss-loader