为什么ExtractTextPlugin.extract会产生“ __webpack_require __(...)不是函数”错误

威彻特·阿克曼

我有假设SASS文件的标准Webpack规则:

        {
          test: /\.scss$/,
          use: ExtractTextPlugin.extract({
                  fallback: 'style-loader',
                  use: [
                      {
                          loader: 'css-loader',
                          options: {
                              minimize: isProduction,
                              sourceMap: true,
                              importLoaders: 1
                          },
                      },
                    {
                      loader: 'resolve-url-loader',
                    },
                    {
                        loader: 'sass-loader',
                        options: {
                          sourceMap: true,
                        },
                    },
                    {
                      loader: 'postcss-loader',
                      options: {
                          sourceMap: !!isProduction,
                          config: {
                              path: './postcss.config.js'
                          }
                      }
                  },
                ],
              })
      },

但是,这似乎会产生错误:

Module build failed: TypeError: __webpack_require__(...) is not a function
    at Object.<anonymous> (/Users/wichert/CurveTips/ws/display/node_modules/css-loader/index.js??ref--2-2!/Users/wichert/CurveTips/ws/display/node_modules/resolve-url-loader/index.js!/Users/wichert/CurveTips/ws/display/node_modules/sass-loader/lib/loader.js??ref--2-4!/Users/wichert/CurveTips/ws/display/node_modules/postcss-loader/lib/index.js??ref--2-5!/Users/wichert/CurveTips/ws/display/packages/display-site/src/assets/styles/curvetips.scss:102:50)
    at __webpack_require__ (/Users/wichert/CurveTips/ws/display/node_modules/css-loader/index.js??ref--2-2!/Users/wichert/CurveTips/ws/display/node_modules/resolve-url-loader/index.js!/Users/wichert/CurveTips/ws/display/node_modules/sass-loader/lib/loader.js??ref--2-4!/Users/wichert/CurveTips/ws/display/node_modules/postcss-loader/lib/index.js??ref--2-5!/Users/wichert/CurveTips/ws/display/packages/display-site/src/assets/styles/curvetips.scss:22:30)
    at module.exports.module.exports (/Users/wichert/CurveTips/ws/display/node_modules/css-loader/index.js??ref--2-2!/Users/wichert/CurveTips/ws/display/node_modules/resolve-url-loader/index.js!/Users/wichert/CurveTips/ws/display/node_modules/sass-loader/lib/loader.js??ref--2-4!/Users/wichert/CurveTips/ws/display/node_modules/postcss-loader/lib/index.js??ref--2-5!/Users/wichert/CurveTips/ws/display/packages/display-site/src/assets/styles/curvetips.scss:65:18)
    at Object.<anonymous> (/Users/wichert/CurveTips/ws/display/node_modules/css-loader/index.js??ref--2-2!/Users/wichert/CurveTips/ws/display/node_modules/resolve-url-loader/index.js!/Users/wichert/CurveTips/ws/display/node_modules/sass-loader/lib/loader.js??ref--2-4!/Users/wichert/CurveTips/ws/display/node_modules/postcss-loader/lib/index.js??ref--2-5!/Users/wichert/CurveTips/ws/display/packages/display-site/src/assets/styles/curvetips.scss:68:10)
    at Module._compile (module.js:660:30)
    at Object.exec (/Users/wichert/CurveTips/ws/display/node_modules/webpack/lib/NormalModule.js:129:12)
    at /Users/wichert/CurveTips/ws/display/node_modules/extract-text-webpack-plugin/dist/loader.js:131:26
    at compile (/Users/wichert/CurveTips/ws/display/node_modules/webpack/lib/Compiler.js:300:11)
    at applyPluginsAsync.err (/Users/wichert/CurveTips/ws/display/node_modules/webpack/lib/Compiler.js:510:14)
    at next (/Users/wichert/CurveTips/ws/display/node_modules/tapable/lib/Tapable.js:202:11)
    at Compiler.<anonymous> (/Users/wichert/CurveTips/ws/display/node_modules/extract-text-webpack-plugin/dist/loader.js:112:7)
    at next (/Users/wichert/CurveTips/ws/display/node_modules/tapable/lib/Tapable.js:204:14)
    at Compiler.<anonymous> (/Users/wichert/CurveTips/ws/display/node_modules/awesome-typescript-loader/src/instance.ts:442:13)
    at next (/Users/wichert/CurveTips/ws/display/node_modules/tapable/lib/Tapable.js:204:14)
    at Compiler.<anonymous> (/Users/wichert/CurveTips/ws/display/node_modules/webpack/lib/CachePlugin.js:78:5)
    at Compiler.applyPluginsAsyncSeries (/Users/wichert/CurveTips/ws/display/node_modules/tapable/lib/Tapable.js:206:13)
    at compilation.seal.err (/Users/wichert/CurveTips/ws/display/node_modules/webpack/lib/Compiler.js:507:11)
    at Compilation.applyPluginsAsyncSeries (/Users/wichert/CurveTips/ws/display/node_modules/tapable/lib/Tapable.js:195:46)
    at self.applyPluginsAsync.err (/Users/wichert/CurveTips/ws/display/node_modules/webpack/lib/Compilation.js:680:19)
    at Compilation.applyPluginsAsyncSeries (/Users/wichert/CurveTips/ws/display/node_modules/tapable/lib/Tapable.js:195:46)
    at self.applyPluginsAsync.err (/Users/wichert/CurveTips/ws/display/node_modules/webpack/lib/Compilation.js:671:11)
    at next (/Users/wichert/CurveTips/ws/display/node_modules/tapable/lib/Tapable.js:202:11)
    at Compilation.<anonymous> (/Users/wichert/CurveTips/ws/display/node_modules/uglifyjs-webpack-plugin/dist/index.js:244:6)
    at next (/Users/wichert/CurveTips/ws/display/node_modules/tapable/lib/Tapable.js:204:14)
    at Compilation.compilation.plugin (/Users/wichert/CurveTips/ws/display/node_modules/webpack/lib/BannerPlugin.js:67:5)
    at next (/Users/wichert/CurveTips/ws/display/node_modules/tapable/lib/Tapable.js:204:14)
    at Compilation.<anonymous> (/Users/wichert/CurveTips/ws/display/node_modules/uglifyjs-webpack-plugin/dist/index.js:244:6)
    at Compilation.applyPluginsAsyncSeries (/Users/wichert/CurveTips/ws/display/node_modules/tapable/lib/Tapable.js:206:13)
    at self.applyPluginsAsync.err (/Users/wichert/CurveTips/ws/display/node_modules/webpack/lib/Compilation.js:666:10)
    at Compilation.applyPluginsAsyncSeries (/Users/wichert/CurveTips/ws/display/node_modules/tapable/lib/Tapable.js:195:46)

删除ExtractTextPlugin.extract调用并直接使用我的加载程序列表可以很好地工作,这使我怀疑ExtractTextPlugin.extract中缺少某些内容。

假单胞菌属

将您的webpack更新到版本3.6.0。这对我有用!

"devDependencies": { "@biesbjerg/ngx-translate-extract": "^2.3.4", "@types/jasmine": "2.5.36", "@types/node": "6.0.45", "angular2-template-loader": "0.6.0", "awesome-typescript-loader": "3.0.4", "copy-webpack-plugin": "^4.4.1", "css-loader": "0.26.1", "extract-text-webpack-plugin": "3.0.0", "file-loader": "0.9.0", "html-loader": "0.4.3", "html-webpack-plugin": "2.16.1", "node-sass": "^4.7.2", "null-loader": "0.1.1", "postcss-loader": "^2.1.0", "resolve-url-loader": "^2.2.1", "rimraf": "2.5.2", "sass-loader": "^6.0.6", "style-loader": "0.20.2", "svg-sprite-loader": "^3.6.2", "to-string-loader": "^1.1.5", "tslint": "5.7.0", "typescript": "2.4.2", "url-loader": "^0.6.2", "webpack": "3.6.0", "webpack-dev-server": "2.9.0", "webpack-merge": "^3.0.0" }

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

未捕获的TypeError:__webpack_require __(…).context不是函数

TypeError:__webpack_require __。i(...)不是一个函数

为什么在头文件中定义函数会产生多个定义错误,而不是类?

诊断未捕获的TypeError:__webpack_require __(...)。createServer不是函数吗?

反应水合物TypeError:__webpack_require __。i(...)不是函数

语义ui react __webpack_require __。i(...)不是一个函数

为什么在Dafny函数中使用new会产生错误?

为什么我的函数会产生“冲突类型”错误?

为什么此代码会产生错误?

为什么 TextInputEditText 会产生此错误?

为什么这种转换会产生错误?

为什么调用与成员函数同名的非成员函数会产生错误

为什么在构造函数中调用这个函数会产生 stackoverflow 错误?

为什么这种错误的python格式会产生此结果,而不是异常?

为什么在日志中getWidth会产生问题,而不是getHeight?

使用已实现接口的函数会产生“不是函数”错误

为什么'arr.values()'会引发错误“ arr.values不是函数”

为什么这个C ++函数会产生混乱的输出?

PHP:为什么ERROR常量会产生错误?

为什么我的总时间公式会产生错误的结果?

为什么我的shellcode测试程序会产生段错误?

为什么“ npm doctor”会产生权限错误?

为什么这段代码会产生错误的P值?

为什么在我的代码中使用宏会产生错误?

为什么交换方程的 LHS 和 RHS 会产生错误?

为什么使用str.format会产生unicode错误?

为什么在此代码中使用>会产生错误?

GHC为什么会产生以下错误消息?

为什么VS2013中的#warning会产生错误?