Adapted from https://github.com/babel/babili/tree/master/packages/babel-plugin-transform-node-env-inline
babel-plugin-transform-babel-env-inline
Inline the BABEL_ENV
environment variable and if it's a part of a binary expression
(eg. process.env.BABEL_ENV === "react"
) then statically evaluate and replace it.
Example
In
processenvBABEL_ENV === "react";processenvBABEL_ENV === "inferno";
Out
BABEL_ENV=react babel in.js --plugins transform-babel-env-inline
true;false;
Installation
npm install babel-plugin-transform-babel-env-inline
Usage
.babelrc
(Recommended)
Via .babelrc
Via CLI
babel --plugins transform-babel-env-inline script.js
Via Node API
;