Babili is deprecated and has been renamed to babel-minify
, so you should be using that instead.
npm install babel-preset-minify --save-dev
To disable the minification in development you simply don't use the babel-preset-minify
(or babel-preset-babili
for that matter). As you're using Gulp you can use everything Node.js has to offer to decide which presets you want to include, which means that you can check process.env.NODE_ENV
and decide whether you want to include the minify
preset.
watchifysForBundle[jsBundle]
.transform(babelify, {
presets: process.env.NODE_ENV === 'production' ? ['minify'] : [],
ignore: ['buffer']
})
An alternative would be to use Babel's env
option (not to confuse with babel-preset-env
), which uses the configuration that matches the value of BABEL_ENV
or NODE_ENV
if no BABEL_ENV
was defined. This approach is shown in babel-preset-minify
- Usage.
{
"env": {
"production": {
"presets": ["minify"]
}
}
}
The env
option is not really recommended and mainly exists because .babelrc
is JSON and there is no good way to define conditional configurations. This will change in Babel 7 which allows a .babelrc.js
config where you have the full power of Node.js and that means you could do the same thing as with Gulp.