When I uses babel to watch a jsx file. But there is a syntax error.
Before that, I uses react-tools to watch, and everything is fine.
SyntaxError: as
Which version of babel you have? If you upgraded to 6, you have to add react preset...
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel",
query:
{
presets:['react', 'es2015', 'stage-0']
}
}
I had a similar issue the other day. It seems that babel now needs some additional plugins to work with react.
See the answer in this SO question: babel-loader jsx SyntaxError: Unexpected token
command:
babel --watch assets/js/ --out-dir dist/js/ --presets react
or package.json:
{
"name": "myweb",
"version": "1.0.0",
"babel": {
"presets": ["react"]
}
}