Code Monkey home page Code Monkey logo

babel-plugin-inline-dotenv's Introduction

babel-plugin-inline-dotenv

Test

npm package

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

The plugin support 3 mode to read the env var from the system :

{
  "plugins": [["inline-dotenv",{
    systemVar: 'all' | 'overwrite' | 'disable'
  }]]
}
  • all default, every env var found in process.env will be used

    โš ๏ธ This could leak super secret stuffs !

  • overwrite, the value in process.env will overwrite the one present in .env only. Your .env file act as a whitelist

  • disable, the process.env will not be used at all

Via CLI

$ babel --plugins inline-dotenv script.js

Via Node API

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

babel-plugin-inline-dotenv's People

Contributors

brysgo avatar dependabot-preview[bot] avatar dependabot[bot] avatar greenkeeper[bot] avatar jwaldrip avatar jzimmek avatar platane avatar pruge avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.