Babel-loader: Impossible to override .babelrc

Created on 16 Apr 2016  路  3Comments  路  Source: babel/babel-loader

I try to use two different config for babel - one for gulp with commonjs modules [es2015] preset and the other for webpack es2015-webpack. But it does not seems to be possible, because [email protected] always use .babelrc configuration:

{
  "presets": ["es2015"]
}

instead one written in webpack.config.js

...
loaders: [{
      test: /\.jsx?$/,
      include: __dirname + '/src',
      loader: 'babel',
      babelrc: false,
      query: {
        presets: ['es2015-webpack']
      }
    }]
...

Most helpful comment

I figure it out. The option babelrc: false should be inside query.

All 3 comments

I figure it out. The option babelrc: false should be inside query.

Just an pointer, I wrote https://github.com/STRML/babel-plugin-es2015-maybe-webpack for this purpose. You can toggle the commonjs plugin by just exporting your webpack version. If webpack2, it will be excluded.

The purpose is different in my case. It allows to use es6 module syntax in server code and tools, so .babelrc with presets: ['es2015-node6'] will be used for node and tools, while presets: ['es2015-webpack'] will be used in webpack.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NXTaar picture NXTaar  路  22Comments

adamziel picture adamziel  路  73Comments

MatTheCat picture MatTheCat  路  20Comments

julen picture julen  路  23Comments

tusharmath picture tusharmath  路  55Comments