jzimmek / babel-plugin-inline-dotenv

Load your .env file and replace 'process.env.MY_VARIABLE' with the value you set.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

babel-plugin-inline-dotenv

Greenkeeper badge

status

Load your .env file and replace process.env.MY_VARIABLE with the value you set.

tl;dr

It actually replaces process.env.MY_VARIABLE with:

process && process.env && process.env.MY_VARIABLE || 'value assigned to variable in dotenv'

This way, if the value is available at runtime it will be used instead.

Installation

$ npm install babel-plugin-inline-dotenv

Usage

Via .babelrc (Recommended)

Without options:

.babelrc

{
  "plugins": ["inline-dotenv"]
}

With options:

{
  "plugins": [["inline-dotenv",{
    path: 'path/to/.env' // See motdotla/dotenv for more options
  }]]
}

Via CLI

$ babel --plugins inline-dotenv script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["inline-dotenv"]
});

About

Load your .env file and replace 'process.env.MY_VARIABLE' with the value you set.


Languages

Language:JavaScript 100.0%