Skip to content
Load your .env file and replace 'process.env.MY_VARIABLE' with the value you set.
Branch: master
Clone or download
brysgo Merge pull request #20 from brysgo/greenkeeper/dotenv-expand-5.0.0
Update dotenv-expand to the latest version 🚀
Latest commit 41c18bd Mar 14, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
src
test
.babelrc
.env add dotenv-expand support Dec 15, 2017
.eslintrc test(simple-case): add a test suite like the react transform Sep 16, 2017
.gitignore test(simple-case): add a test suite like the react transform Sep 16, 2017
README.md feat: add optional unsafe mode, fixes #16 Nov 8, 2018
package.json Merge pull request #20 from brysgo/greenkeeper/dotenv-expand-5.0.0 Mar 14, 2019
yarn.lock

README.md

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
  }]]
}

To replace with env value without process && process.env && process.env.MY_VARIABLE || safety:

{
  "plugins": [["inline-dotenv",{
    unsafe: true
  }]]
}

Via CLI

$ babel --plugins inline-dotenv script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["inline-dotenv"]
});
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.