Javascript Chunk.entrypoints:使用 Chunks.groupsIterable 并通过 instanceof Entrypoint 进行过滤
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51383618/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead
提问by Drostan
I see the following errors when trying to start my app...
尝试启动我的应用程序时,我看到以下错误...
> [email protected] start /Users/johnnynolan/Repos/css-modules
webpack && open index.html
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! [email protected] start: `webpack && open index.html`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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
回答by Steven McConnon
npm install extract-text-webpack-plugin@next
This did the trick for me!
这对我有用!
回答by Rikin
Most of the comments here https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/701point to extract-text-pluginchange it to mini-css-extract-plugininstead.
这里的大部分评论https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/701指向extract-text-plugin改为mini-css-extract-plugin改为。
From the Github repo of extract-text-webpack-pluginhttps://github.com/webpack-contrib/extract-text-webpack-plugin
来自https://github.com/webpack-contrib/extract-text-webpack-plugin的 Github 存储库extract-text-webpack-plugin
?? Since webpack v4 the extract-text-webpack-plugin should not be used for css. Use mini-css-extract-plugin instead.
?? 从 webpack v4 开始,extract-text-webpack-plugin 不应该用于 css。请改用 mini-css-extract-plugin。
Head over to
mini-css-extract-pluginon how to swap/upgrade it
https://github.com/webpack-contrib/mini-css-extract-plugin
转到
mini-css-extract-plugin如何交换/升级它
https://github.com/webpack-contrib/mini-css-extract-plugin
回答by Eric Tan
Yea, I got the same issue with webpack 4.10.2. The problem is fixed after I swap the extract-css-chunks-webpack-pluginto mini-css-extract-plugin.
是的,我在 webpack 上遇到了同样的问题4.10.2。我交换extract-css-chunks-webpack-plugin到后问题就解决了mini-css-extract-plugin。
Here's the webpack config changes:
这是 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........
//
]
Hope it can help.
希望它能有所帮助。
回答by TurboHZW
I had fixed the bug by using the version 4.0.0-beta.0of extract-text-webpack-plugin.
我已经使用版本修复了这一错误4.0.0-beta.0的extract-text-webpack-plugin。

