Skip to content Skip to sidebar Skip to footer

Webpack + Babel - React, Unexpected Token 'import'

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 sure, but there's no react here). It features imp

Solution 1:

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" }
  ],
}

Post a Comment for "Webpack + Babel - React, Unexpected Token 'import'"