Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
72 lines (52 sloc) 1.16 KB
id title sidebar_label
babel-plugin-transform-inline-environment-variables
babel-plugin-transform-inline-environment-variables
transform-inline-environment-variables

Example

In

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

Out

"development";

Installation

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

Usage

Via .babelrc (Recommended)

.babelrc

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

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

Via CLI

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

Via Node API

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

Options

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

You can read more about configuring plugin options here

You can’t perform that action at this time.