Skip to content

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

Notifications You must be signed in to change notification settings

efossvold/babel-plugin-inline-dotenv-expanded

 
 

Repository files navigation

babel-plugin-inline-dotenv-expanded

Forked from babel-plugin-inline-env and inspired by node-dotenv-extended to support a common .env.defaults file which other .env.* can inherit from. Load your .env and replace process.env.MY_VARIABLE with the value you set. Variable expansion (as in dotenv-expand) is supported. This means any variables in .env.defaults can also be expanded in the .env.* files.

It 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-expanded

Usage

Via .babelrc (Recommended)

Without options:

.babelrc

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

With options:

{
  "plugins": [["inline-dotenv-expanded",{
    path: 'path/to/.env'
  }]]
}

Via CLI

pm

$ babel --plugins inline-env script.js

Via Node API

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

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.0%
  • Shell 1.0%