Webpack + Babeljs无法转换ES6

时间:2017-08-29 09:41:31

标签: webpack vue.js babeljs

我正在使用vue-cli构建一个javascript Web应用程序。

我注意到已编译的javascript代码中有一些const个关键字。浏览器说SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode

编译后的代码如下:

"use strict";
eval("/*blabla*/ const xxx ...");

我的babelrc:

{
  "presets": [
    ["env", {
      "modules": false,
      "targets": {
        "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
      }
    }],
    "stage-2"
  ],
  "plugins": ["transform-runtime"],
  "env": {
    "test": {
      "presets": ["env", "stage-2"],
      "plugins": ["istanbul"]
    }
  }
}

babel-loader配置文件如下:

  {
    test: /\.js$/,
    loader: 'babel-loader',
    include: [resolve('src'), resolve('test')]
  },

0 个答案:

没有答案