webpack + babel - react, unexpected token 'import'

前端 未结 1 1490
感情败类
感情败类 2021-02-05 08:20

I\'m trying to make index.js work with es2015.

Before directing me to .babelrc, note that I have added BOTH es2015 and react (to be sur

1条回答
  •  醉话见心
    2021-02-05 09:16

    Your webpack.config.js structure is not correct. Webpack doesn't recognize all your loaders. Specifically, you need to put the loaders property inside of a module section like this:

    module: {
       loaders: [
        { test: /\.js$/,
          loader: 'babel-loader',
          exclude: /node_modules/
        },
        { test: /\.css$/, loader: "style!css" },
        { test: /\.(png|jpg|jpeg|gif|woff)$/, loader: 'url?limit=8192' },
        { test: /\.(otf|eot|ttf)$/, loader: "file?prefix=font/" },
        { test: /\.svg$/, loader: "file" }
      ],
    }
    

    0 讨论(0)
提交回复
热议问题