Webpack 节点v9+;网页包v4+;提取文本网页包插件=编译错误
使用时:Webpack 节点v9+;网页包v4+;提取文本网页包插件=编译错误,webpack,Webpack,使用时: //webpack.config.js -- shortened for convenience const ExtractTextPlugin = require("extract-text-webpack-plugin"), extractSass = new ExtractTextPlugin({ filename: "Css/[name].css", allChunks: true }), //… config: { modu
//webpack.config.js -- shortened for convenience
const
ExtractTextPlugin = require("extract-text-webpack-plugin"),
extractSass = new ExtractTextPlugin({
filename: "Css/[name].css",
allChunks: true
}),
//…
config: {
module: {
rules: [
//…
{
test: /\.scss$/,
use: extractSass.extract([ 'css-loader', 'sass-loader' ])
}
//…
]
},
plugins: [
extractSass
]
}
module.exports = config;
0%编译(节点:333)不推荐使用警告:Tapable.plugin不推荐使用。改为在“.hooks”上使用新API
(节点:333)弃用警告:Tapable.apply已弃用。直接调用插件上的apply
77%模块和区块树优化未命名compat plugin/xxx/node_modules/webpack/lib/chunk.js:460
抛出新错误(
^
错误:Chunk.entrypoints:使用Chunks.groupsIterable并改为按Entrypoint的实例进行筛选
在Chunk.get(/xxx/node_modules/webpack/lib/Chunk.js:460:9)
at/xxx/node_modules/extract text webpack plugin/dist/index.js:176:48
在Array.forEach()处
at/xxx/node_modules/extract text webpack plugin/dist/index.js:171:18
在AsyncSeriesHook.eval[as callAsync](eval在create(/xxx/node_modules/tapable/lib/HookCodeFactory.js:24:12),:12:1)
在AsyncSeriesHook.lazycilehook[as _callAsync](/xxx/node_modules/tapable/lib/Hook.js:35:21)
在Compilation.seal(/xxx/node_modules/webpack/lib/Compilation.js:881:27)
在hooks.make.callAsync.err(/xxx/node_modules/webpack/lib/Compiler.js:464:17)
at_err0(在创建时求值(/xxx/node_modules/tapable/lib/HookCodeFactory.js:24:12),:11:1)
在_addModuleChain(/xxx/node_modules/webpack/lib/Compilation.js:749:12)
在processModuleDependencies.err(/xxx/node_modules/webpack/lib/Compilation.js:688:9)
在进程中。_tick回调(内部/process/next_tick.js:150:11)
该设置一直运行到webpack v4。禁用插件会使错误消失。我发现webpack插件系统已更改,但我无法确定如何修复该错误。如前所述,问题在于提取文本webpack插件
需要升级才能使用webpack v4
。因此:
0% compiling(node:333) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
(node:333) DeprecationWarning: Tapable.apply is deprecated. Call apply on the plugin directly instead
77% module and chunk tree optimization unnamed compat plugin/xxx/node_modules/webpack/lib/Chunk.js:460
throw new Error(
^
Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead
at Chunk.get (/xxx/node_modules/webpack/lib/Chunk.js:460:9)
at /xxx/node_modules/extract-text-webpack-plugin/dist/index.js:176:48
at Array.forEach (<anonymous>)
at /xxx/node_modules/extract-text-webpack-plugin/dist/index.js:171:18
at AsyncSeriesHook.eval [as callAsync] (eval at create (/xxx/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:12:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (/xxx/node_modules/tapable/lib/Hook.js:35:21)
at Compilation.seal (/xxx/node_modules/webpack/lib/Compilation.js:881:27)
at hooks.make.callAsync.err (/xxx/node_modules/webpack/lib/Compiler.js:464:17)
at _err0 (eval at create (/xxx/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:11:1)
at _addModuleChain (/xxx/node_modules/webpack/lib/Compilation.js:749:12)
at processModuleDependencies.err (/xxx/node_modules/webpack/lib/Compilation.js:688:9)
at process._tickCallback (internal/process/next_tick.js:150:11)
这肯定会解决问题。对于webpack v4,似乎不推荐使用extract text webpack插件。请参阅,其中说明: ⚠️ 由于webpack v4,提取文本webpack插件不应用于css。请改用
本期提供了更多关于不推荐的信息。使用此版本的“extract text webpack plugin”:“^4.0.0-beta.0”下一个版本指的是什么版本?是否仍然需要它?这不是正确的答案,因为extract text webpack plugin不应用于css,而是--请参阅本页上的其他答案。
npm install extract-text-webpack-plugin@next