error in webpack module loaders

2

I find the next brake,

I am adding some loaders to my webpack.config.js The code is as follows:

module.exports = {
    mode: 'development',
    entry: './test.js',
    output: {
        filename: 'bundle.js',
        path: __dirname
    },
    module: {
        loaders: [
                    {
                        test: /(\.js|.jsx)$/,
                        loader: 'babel',
                        query: {
                          presets: ['es2015', 'stage-2', 'react']
                        }
                    }
        ]
    }
};

And when running the webpack watch

webpack --watch

I see the following error by console:

  

Invalid configuration object. Webpack has been initialized using a   configuration object that does not match the schema API.    - configuration.module has an unknown property 'loaders'. These properties are valid: object {exprContextCritical?   exprContextRecursive ?, exprContextRegExp ?, exprContextRequest ?,   noParse ?, rules ?, defaultRules ?, unknownContextCritical ?,   unknownContextRecursive ?, unknownContextRegExp ?,   unknownContextRequest ?, unsafeCache ?, wrappedContextCritical ?,   wrappedContextRecursive ?, wrappedContextRegExp ?,   strictExportPresence ?, strictThisContextOnImports? } - > Options   affecting the normal modules ( NormalModuleFactory ).

It should be noted that if I delete the loaders I do not see any error

    
asked by Pablo 20.04.2018 в 15:29
source

1 answer

1

It seems that your configuration should be something like:

module.exports = {
  mode: 'development',
  entry: './test.js',
    output: {
      filename: 'bundle.js',
      path: __dirname
    },
    module: {
      rules: [
        {
          test: /(\.js|.jsx)$/,
          use: {
            loader:'babel',
            options: {
              presets: ['es2015', 'stage-2', 'react']
            }
          }
        }
      ]
    }
};
    
answered by 20.04.2018 в 18:12