1.1.3 • Published 3 years ago

babel-plugin-inline-dotenv-expanded v1.1.3

Weekly downloads
12
License
ISC
Repository
github
Last release
3 years ago

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"]
});