babel-plugin-transform-node-env-inline

Example

In

  1. process.env.NODE_ENV === "development";
  2. process.env.NODE_ENV === "production";

Out

  1. NODE_ENV=development babel in.js --plugins transform-node-env-inline
  1. true;
  2. false;

Installation

  1. npm install babel-plugin-transform-node-env-inline --save-dev

Usage

.babelrc

  1. {
  2. "plugins": ["transform-node-env-inline"]
  3. }

Via CLI

  1. babel --plugins transform-node-env-inline script.js

Via Node API

  1. require("@babel/core").transform("code", {
  2. plugins: ["transform-node-env-inline"]
  3. });