Webpack ReactJS

0

I'm experiencing problems with my webpack, I get the following error in the terminal:

You may need an appropriate loader to handle this file type

webpack.config.js:

var path = require('path');
var webpack = require('webpack');

var DIST_DIR = path.resolve(__dirname, 'src/client/public');
var SRC_DIR = path.resolve(__dirname, 'src');

module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'bundle.js'
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
        query: {
          presets: ['react', 'es2015']
        }
      }
    ]
  },
};

package.json:

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.17.0",
    "font-awesome": "^4.7.0",
    "react": "^16.0.0",
    "react-bootstrap": "^0.31.5",
    "react-dom": "^16.0.0",
    "react-if": "^2.2.1",
    "react-scripts": "1.0.16",
    "react-simple-chatbot": "^0.2.9",
    "recharts": "^1.0.0-beta.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "webpack": "webpack",
    "babel": "babel",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "webpack": "^3.8.1",
    "webpack-dev-server": "^2.9.4"
  }
}
    
asked by anonymous 26.11.2017 / 17:14

1 answer

0

Hi, for webpack version 2 and 3, module.loaders changed to the following format:

module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['react', 'es2015']
          },
        }
      }
    ]
  },
// ...

Note that it is now module.rules

    
29.11.2017 / 18:28