How to use the babelrc
The entire range of Babel API options are allowed.
Example:
{
"stage": 1,
"loose": ["es6.modules", "es6.classes"],
"ignore": [
"foo.js",
"bar/**/*.js"
]
}
env
optionYou can use the env
option to set specific options when in a certain environment:
{
"env": {
"production": {
"optional": ["optimisation", "minification"]
}
}
}
The env
key will be taken from process.env.BABEL_ENV
, when this is not available then it uses
process.env.NODE_ENV
if even that is not available then it defaults to "development"
.
You can set this environment variable with the following:
Unix
# at the start of a command
$ BABEL_ENV=production YOUR_COMMAND_HERE
# or as a separate command
$ NODE_ENV=production
$ YOUR_COMMAND_HERE
Windows
$ SET BABEL_ENV=production
$ YOUR_COMMAND_HERE
package.json
You can alternatively choose to specify your .babelrc
config from within package.json
like so:
{
"name": "my-package",
"version": "1.0.0",
"babel": {
// my babel config here
}
}