I have the following code (es6 spread Attribute):
return {...state, name: action.payload};
The error thrown is: You may need an appropriate loader to handle this file type.
package.json
What else do I need to install in order to make this work. All the other ES6 is working but the spread attribute isn't.
webpack.config.js
To use ecmascript-6
you need to (1) add .babelrc
file with the following presets
{
"presets": [ "es2015" ]
}
es2015
is the particular one you need.
And then (2) configure your webpack to include
module.exports = {
...,
loaders : [
{ test: /\.js$/, exclude: /(node_modules)/, loader: 'babel-loader' }
]
}
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