关于babe-loader^8.0.6的配置问题

1、报错报regeneratorRuntime is not defined 错误

.babelrc配置

{
    // https://babeljs.io/docs/en/babel-plugin-transform-runtime#options
    "plugins": [
        "@babel/plugin-transform-runtime"
    ],
    // https://babeljs.io/docs/en/babel-plugin-transform-runtime#options
    "presets": [
        [
            "@babel/preset-env"
        ]
    ]
}

  npm安装

npm i @babel/plugin-transform-runtime @babel/preset-env @babel/runtime --save-dev

  版本

"devDependencies": {
    "@babel/plugin-transform-runtime": "^7.7.6",
    "@babel/preset-env": "^7.7.7",
    "@babel/runtime": "^7.7.7",
   "babel-loader": "^8.0.6",
   "@babel/core": "^7.8.3",
  },

webpack配置

module: {
    rules: [{
      test: /\.js$/,
      exclude: /(node_modules|bower_components)/,
      use: {
        loader: 'babel-loader',
        options: {
          presets: ['@babel/preset-env'],
//"plugins": [
   //     "@babel/plugin-transform-runtime",{
    //  corejs:3
    //}
    ],
        }
      }
    }
    ]
  }

  

posted @ 2020-01-03 16:47  地铁程序员  阅读(323)  评论(0编辑  收藏  举报