babel-plugin-transform-inline-environment-variables

Example

In

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

Out

  1. "development";

Installation

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

Usage

  1. // without options
  2. {
  3. "plugins": ["transform-inline-environment-variables"]
  4. }
  5. // with options
  6. {
  7. "plugins": [
  8. ["transform-inline-environment-variables", {
  9. "include": [
  10. "NODE_ENV"
  11. ]
  12. }]
  13. ]
  14. }

Via CLI

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

Via Node API

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

Options

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

You can read more about configuring plugin options here