I have an issue in my react project. I am using webpack dev server to serve my files. the webpack build is successful but I am getting an error on the browser like
"app.js:7 Uncaught SyntaxError: Unexpected token import"
in the line:
import React from 'react';
Below is my webpack.config.js
module.exports = {
context: __dirname + "/app",
entry: "./app.js", output: {
filename: "app.build.js",
path: __dirname + "/dist",
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ["react-hot-loader", "babel-loader"],
},
{
test: /\.html$/,
loader: "file?name=[name].[ext]",
},
{
test: /\.js$/,
exclude: /node_modules/,
loaders: ["react-hot-loader", "babel-loader"],
}
]
}
};
And in my .babelrc
I have
{
"presets": ["react", "es2015"]
}
I have tried adding various babel configs like using stage-0, stage-2, etc., but none of them worked. Is there any way to fix this.