Set up different environments in your .babelrc
{
"env": {
"dev": {
"presets": ["es2015"],
"plugins":["x"]
},
"test": {
"presets": ["es2015"]
}
}
}
And then run babel after you have set your BABEL_ENV
BABEL_ENV=test <commandhere> or BABEL_ENV=dev <commandhere>
If you don’t set BABEL_ENV, babel will use the NODE_ENV value.
If you don’t set either BABEL_ENV nor NODE_ENV, it will use ‘development’.
CODE BELOW:
function getEnv(defaultValue = "development") {
return process.env.BABEL_ENV || process.env.NODE_ENV || defaultValue;
}