Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

You may need an appropriate loader to handle this file type-error

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

enter image description here

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

enter image description here

like image 640
Eugen Sunic Avatar asked Sep 06 '25 10:09

Eugen Sunic


1 Answers

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' }
  ]
}
like image 199
Deividas Karzinauskas Avatar answered Sep 08 '25 11:09

Deividas Karzinauskas