babel-plugin-transform-node-env-inline
Example
In
JavaScript
process.env.NODE_ENV === "development";
process.env.NODE_ENV === "production";
Out
Shell
NODE_ENV=development babel in.js --plugins transform-node-env-inline
JavaScript
true;
false;
Installation
- npm
- Yarn
- pnpm
npm install babel-plugin-transform-node-env-inline --save-dev
yarn add babel-plugin-transform-node-env-inline --dev
pnpm add babel-plugin-transform-node-env-inline --save-dev
Usage
With a configuration file (Recommended)
babel.config.json
{
"plugins": ["transform-node-env-inline"]
}
Via CLI
Shell
babel --plugins transform-node-env-inline script.js
Via Node API
JavaScript
require("@babel/core").transformSync("code", {
plugins: ["transform-node-env-inline"],
});