Core-JS 3 Babel导致mini-css-extract-plugin错误 [英] Core-JS 3 Babel results in mini-css-extract-plugin error

查看:111
本文介绍了Core-JS 3 Babel导致mini-css-extract-plugin错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

接着这个问题设置我的Webpack 4配置以处理 babel-loader 这样

Following on from this question I have set up my Webpack 4 config to handle babel-loader like this

{
  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
            }
          }]
        ]
      }
    }
  }
}

当我在浏览器中运行此程序时,出现此错误,我不理解:

When I run this in the browser I get this error which I do not understand:

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

此问题的解决方法是什么?跟随这个问题,我到处都在搜索代码开始导入'core-js ,但是在任何地方都看不到它,因此已经陷入僵局.

What is the fix for this? Following this question I have searched everywhere for code starting import 'core-js but cannot see it anywhere so have reached a dead end.

推荐答案

我有一个类似的问题,原因是Babel正在编译我的css-loader webpack插件.在此处查看:入口点构建时发生MiniCssExtractPlugin错误

I had a similar problem and the reason was that Babel was transpiling my css-loader webpack plugin. Look here: MiniCssExtractPlugin error on entry point build

这篇关于Core-JS 3 Babel导致mini-css-extract-plugin错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆