Thursday, June 8, 2017

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

When using webpack 2 with React, if you get a compile time error stating "You may need an appropriate loader to handle this file type.", and pointing to a JSX code block:

Make sure your babel-loader has appropriate include setting value.

An example:

rules:{

    {
         test:/\.jsx?$/,
         use:
         [
           {
                 loader:'babel-loader',
                 options:{presets:['es2015', 'react']},
                 include:__dirname

          ]

   }
}

If include is set to a wrong path (not pointing to your source files), you're likely to see the error above. Tested with weback 2.6.

No comments:

Post a Comment

Ubuntu 12.04, 14.04, 16.04 - auto start an app or script before login

To run a command or application at startup, even before the user has logged in, you can use this file: /etc/rc.local The commands entered...