Webpack/babel/react - "uncaught Syntaxerror: Unexpected Token :"
I have a webpack-dev-server running that compiles and serves some Babel/React code. I have gotten as far as to have it serve the compiled client.js over localhost:3001. But when I
Solution 1:
I was using webpack's DefinePlugin to set process.env.BABEL_ENV
like this:
newDefinePlugin({
'process.env': {
BABEL_ENV: JSON.stringify('client')
}
});
This resulted in webpack replacing all instances of process.env
in the code with {"BABEL_ENV":"client"}
. The SyntaxError was caused in this part, not in the ternary expression.
I fixed it by setting process.env.BABEL_ENV
like this:
newDefinePlugin({
'process.env.BABEL_ENV': JSON.stringify('client')
});
Post a Comment for "Webpack/babel/react - "uncaught Syntaxerror: Unexpected Token :""