Inline environment variables transform

Inlines environment variables.

Example

For example compiling the following file:

script.js

if (process.env.NODE_ENV === "development") {
  development();
} else {
  production();
}

with the command:

$ NODE_ENV=development babel --plugins transform-inline-environment-variables script.js

outputs:

if ("development" === "development") {
  development();
} else {
  production();
}

Use this in conjunction with the minification.deadCodeElimination transformer to output:

development();

Installation

$ npm install babel-plugin-transform-inline-environment-variables

Usage

Add the following line to your .babelrc file:

{
  "plugins": ["transform-inline-environment-variables"]
}