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']
}
}]
...
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.
Most helpful comment
I figure it out. The option
babelrc: falseshould be inside query.