0.0.1 • Published 7 years ago

babel-plugin-transform-babel-env-inline v0.0.1

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

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

process.env.BABEL_ENV === "react";
process.env.BABEL_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

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["transform-babel-env-inline"]
}

Via CLI

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

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-babel-env-inline"]
});