I am working on a React project and am having trouble getting webpack.config.js
to work, I keep getting SyntaxError: Unexpected token import
on a simple import statement: import path from "path"
I looked at other stackoverflow answers and have modified my configs accordingly but nothing helped so far
webpack.config.js
import path from "path";
module.exports = {
entry: "./src/index.js",
output: {
path: path.resolve("dist"),
filename: "index_bundle.js"
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
query: {
babelrc: false,
presets: [
"stage-0",
"react",
["es2015", { "modules": false }],
["env", {
"targets":
{ "uglify": false }
}
]
]
}
}
]
}
};
.babelrc
{
"presets": ["es2015"]
}
Error am getting:
(function (exports, require, module, __filename, __dirname) { import path from "path";
^^^^^^
SyntaxError: Unexpected token import
Experience with webpack-babel tells me this is something really silly, but I have been pulling my hair out for last couple hours and cant figure.