react with IE11 is not working, displaying blank screen

为君一笑 提交于 2019-12-06 04:50:58

i have updated my webpack and babelrc to the following and it is working now.

.babelrc

{
  "presets": [
    'es2015', "react",
  ]
}

webpack.config.js

module.exports = {
    entry : [__dirname + '/app/index.js'],
    module: {
         rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader'
                }
            } ,
            {
                test: /\.scss$/,
                use: [{
                    loader: "style-loader"
                }, {
                    loader: "css-loader"
                }, {
                    loader: "sass-loader",
                }]
            }
        ],
    },
    output: {
        filename: 'bundle.js',
        path: __dirname + '/docs'
    }
}

Had the same issue and wanted to avoid npm run eject, so I included this script in index.html while in development mode:

<script src="//cdn.polyfill.io/v2/polyfill.min.js"></script>

It worked for me with npx create-react-app my-app version 1 in React v16.6.3

I needed to also test production but 127.0.0.1 didn't work for me either, so I used netlify with command netlify deploy and it worked.

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