簡體   English   中英

Core-JS 3 Babel 導致 mini-css-extract-plugin 錯誤

[英]Core-JS 3 Babel results in mini-css-extract-plugin error

這個問題開始,我已經設置了我的 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

解決方法是什么? 這個問題之后,我到處搜索開始import 'core-js的代碼,但在任何地方都看不到它,所以已經走到了死胡同。

我遇到了類似的問題,原因是 Babel 正在編譯我的 css-loader webpack 插件。 看這里: MiniCssExtractPlugin error on entry point build

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM