I want to handle my jsx code, so I write webpakc.config.js like this:
{
test: /\.js$/,
loaders: ['react-hot', 'babel-loader?presets[]=es2015'],
exclude: /node_modules/
}
But it didn't handle my jsx code and throw an error like this: The error threw in terminal
By Google I find I need to add presets['react']
to my config file. So I update config like this:
{
test: /\.js$/,
loaders: ['react-hot', 'babel'],
query: {
presets: ['react', 'es2015']
},
exclude: /node_modules/
}
But it threw another error: A new error threw after update config file
I am a fresher in webpack, What should I do?
The first error seems to be a syntax error in your JSX. Difficult to tell what it is from the comment. Try posting the JSX file contents.
About the second error: Query params for a specific loader needn't necessarily be specified as a JSON object. You can specify them as a query string adjoining the loader name as well. Eg. the same config can be expressed with this line:
loaders: ['react-hot', 'babel?presets[]=react,presets[]=es2015']
Of course, you'll need to remove the query JSON once you use the above. More info here: https://webpack.github.io/docs/using-loaders.html#query-parameters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With