Skip to main content

babel-plugin-transform-inline-environment-variables

Example

In

JavaScript
// assuming process.env.NODE_ENV is actually "development"
process.env.NODE_ENV;

Out

JavaScript
"development";

Installation

npm install babel-plugin-transform-inline-environment-variables --save-dev

Usage

JSON
// without options
{
"plugins": ["transform-inline-environment-variables"]
}

// with options
{
"plugins": [
["transform-inline-environment-variables", {
"include": [
"NODE_ENV"
]
}]
]
}

Via CLI

Shell
babel --plugins transform-inline-environment-variables script.js

Via Node API

JavaScript
require("@babel/core").transformSync("code", {
plugins: ["transform-inline-environment-variables"],
});

Options

  • include - array of environment variables to include
  • exclude - array of environment variables to exclude
tip

You can read more about configuring plugin options here