【问题标题】:Core-JS 3 Babel results in mini-css-extract-plugin errorCore-JS 3 Babel 导致 mini-css-extract-plugin 错误
【发布时间】:2020-08-18 02:03:47
【问题描述】:

this question 开始,我已经设置了我的 Webpack 4 配置来像这样处理babel-loader

{
  module : {
    rules : [{
      test : /\.js$/,
      // Some module should not be transpiled by Babel
      // See https://github.com/zloirock/core-js/issues/743#issuecomment-572074215
      exclude: ['/node_modules/', /\bcore-js\b/, /\bwebpack\/buildin\b/, /@babel\/runtime-corejs3/],
      loader : "babel-loader",
      options : {
        babelrc : false,
        // Fixes "TypeError: __webpack_require__(...) is not a function"
        // https://github.com/webpack/webpack/issues/9379#issuecomment-509628205
        // https://babeljs.io/docs/en/options#sourcetype
        sourceType : "unambiguous",
        presets : [
          ["@babel/preset-env", {
            // Webpack supports ES Modules out of the box and therefore doesn’t require
            // import/export to be transpiled resulting in smaller builds, and better tree
            // shaking. See https://webpack.js.org/guides/tree-shaking/#conclusion
            modules : false,
            // Adds specific imports for polyfills when they are used in each file.
            // Take advantage of the fact that a bundler will load the polyfill only once.
            useBuiltIns : "usage",
            corejs : {
              version : "3",
              proposals : true
            }
          }]
        ]
      }
    }
  }
}

当我在浏览器中运行它时,我收到了这个我不明白的错误:

Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
TypeError: Cannot convert undefined or null to object

对此有什么解决办法?在this question 之后,我到处搜索以import 'core-js 开头的代码,但在任何地方都看不到它,所以已经走到了死胡同。

【问题讨论】:

    标签: javascript webpack babeljs mini-css-extract-plugin core-js


    【解决方案1】:

    我遇到了类似的问题,原因是 Babel 正在转译我的 css-loader webpack 插件。看这里:MiniCssExtractPlugin error on entry point build

    【讨论】:

      猜你喜欢
      • 2023-01-05
      • 2019-01-29
      • 2021-05-17
      • 2019-10-06
      • 2018-08-30
      • 2019-03-05
      • 2019-12-24
      • 2019-02-03
      • 2019-04-23
      相关资源
      最近更新 更多