You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

babel-plugin-inline-env-vars

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-inline-env-vars

babel plugin to inline all environment variables

1.0.5
latest
Source
npmnpm
Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-inline-env-vars

Plugin which replaces all instances of process.env.*** with the environment variable value.

Aims to have the same functionality as inline-environment-variables-webpack-plugin

Install

npm install --save-dev babel-plugin-inline-env-vars

Usage

Inline all environment variables

If you would like to inline all environment variables then you can just instantiate the plugin without passing any config, as in the following example.

{
  "plugins": [
    "inline-env-vars"
  ]
}

Inline only selected environment variables

You can optionally pass a config in "vars" property of plugin options to select which environment variables you would like to inline.

A config can be either a string an object or an array.

string config

A string config is defined like

{
  "plugins": [
    ["inline-env-vars", {
      "vars": "NODE_ENV"
    }]
  ]
}

The above config will inline process.env.NODE_ENV with the value of process.env.NODE_ENV at build time

object config

an object config is defined like

{
  "plugins": [
    ["inline-env-vars", {
      "vars": { "NODE_ENV": "production" }
    }]
  ]
}

The above config will inline process.env.NODE_ENV with the value specified in the config. So in the above example it would change it to 'production';

array config

and array config is just a list of string and object configs. It would be defined like

{
  "plugins": [
    ["inline-env-vars", {
      "vars": [
        "SOME_VAR",
        "ANOTHER_ONE",
        {
          "NODE_ENV": "production",
          "ONE_MORE": true
        }
      ]
    }]
  ]
}

Disable warnings

Pass in an object with warnings set to false.

{
  "plugins": [
    ["inline-env-vars", {
      "vars": { "NODE_ENV": "production" },
      "warnings": false
    }]
  ]
}

Credits

This plugin is based on:

Keywords

babel

FAQs

Package last updated on 22 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts