Syntax error in IE11 with Webpack, Babel and React

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 22:41:19

I know it's over a year later, but I believe the issue was your devtool configuration:

webpackConfig.devtool = 'eval-source-map';

IE11 isn't a fan of the eval() code that gets inserted by webpack for those, apparently. Using webpackConfig.devtool = 'none' (or one of the alternative values) should fix it.

Install babel-preset-env with npm install babel-preset-env --save-dev and use the following config in your .babelrc:

{
  "presets" : [
    ["env", {
      "targets": {
        "browsers": ["last 2 versions", "ie >= 11"]
      }
    }],
    "react",
  ]
}

You can also remove the following part from your config:

        loaders: [
            {
                /*
                 * Use Babel to compile JS and JSX files
                 * See .babelrc
                 */
                test: /\.jsx?/,
                include: APP_DIR,
                loader: 'babel-loader'
            }
        ],

Check the docs here

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!