Chunk.entrypoints:使用Chunks.groupsIterable并按instanceof Entrypoint进行过滤


91

尝试启动我的应用时,我看到以下错误...

> css-modules@1.0.0 start /Users/johnnynolan/Repos/css-modules

webpack &&打开index.html

(node:5706) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
/Users/johnnynolan/Repos/css-modules/node_modules/webpack/lib/Chunk.js:802
        throw new Error(
        ^

Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead
    at Chunk.get (/Users/johnnynolan/Repos/css-modules/node_modules/webpack/lib/Chunk.js:802:9)
    at /Users/johnnynolan/Repos/css-modules/node_modules/extract-text-webpack-plugin/dist/index.js:176:48
    at Array.forEach (<anonymous>)
    at /Users/johnnynolan/Repos/css-modules/node_modules/extract-text-webpack-plugin/dist/index.js:171:18
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/johnnynolan/Repos/css-modules/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:7:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (/Users/johnnynolan/Repos/css-modules/node_modules/tapable/lib/Hook.js:35:21)
    at Compilation.seal (/Users/johnnynolan/Repos/css-modules/node_modules/webpack/lib/Compilation.js:1203:27)
    at hooks.make.callAsync.err (/Users/johnnynolan/Repos/css-modules/node_modules/webpack/lib/Compiler.js:547:17)
    at _err0 (eval at create (/Users/johnnynolan/Repos/css-modules/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:11:1)
    at _addModuleChain (/Users/johnnynolan/Repos/css-modules/node_modules/webpack/lib/Compilation.js:1054:12)
    at processModuleDependencies.err (/Users/johnnynolan/Repos/css-modules/node_modules/webpack/lib/Compilation.js:980:9)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! css-modules@1.0.0 start: `webpack && open index.html`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the css-modules@1.0.0 start script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /Users/johnnynolan/.npm/_logs/2018-07-17T14_04_42_021Z-debug.log

CSS模块可能会抛出一些东西。发布整个堆栈跟踪和您的webpack配置
PlayMa256 '18

建议您将问题编辑为“如何解决此问题?” 而不是“以前有没有人看过?”
艾米(Amy)

3
extract-text-plugin不适用于Webpack v4
IVO GELOV,

Answers:



82

https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/701 上的大多数评论都指向将其extract-text-plugin更改为mini-css-extract-plugin

来自https://github.com/webpack-contrib/extract-text-webpack-plugin的Github存储库extract-text-webpack-plugin

Since️从webpack v4开始,extract-text-webpack-plugin不应用于CSS。请改用mini-css-extract-plugin。

转至 mini-css-extract-plugin如何交换/升级它 https://github.com/webpack-contrib/mini-css-extract-plugin


21

是的,我在webpack上遇到了同样的问题4.10.2。我将交换extract-css-chunks-webpack-plugin到后,问题已解决mini-css-extract-plugin

这是webpack配置更改:

-const ExtractCssChunks = require('extract-css-chunks-webpack-plugin')
+const MiniCssExtractPlugin = require("mini-css-extract-plugin");

module.exports = {
  name: 'client',
  target: 'web',
  module: {
    rules: [
      {
        test: /\.css$/,
-       use: ExtractCssChunks.extract({
-         use: 'css-loader'
-       })
+       use: [
+         {
+           loader: MiniCssExtractPlugin.loader,
+         },
+         "css-loader"
+       ]
      }
    ]
  },
// 
// other config........
//
   plugins: [
-    new ExtractCssChunks(),
+    new MiniCssExtractPlugin({
+        filename: `components/[name].css`
+    }),
     //
     // other config........
     //
   ]

希望能有所帮助。


它确实比上述答案提供了更多帮助。谢谢。
保罗·斯特凡

7

我已经使用版本修复了这一错误4.0.0-beta.0extract-text-webpack-plugin


4
更新至4.0.0-beta.0也解决了我的问题
JillAndMe

VS Code没有针对4.x的自动完成功能,因此感谢您为我保存了另一个带有明确版本的Google搜索。
steven87vt

那是什么路?
Grald
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.