Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-inline-dotenv

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-inline-dotenv

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

  • 1.7.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
37K
decreased by-0.18%
Maintainers
1
Weekly downloads
 
Created
Source

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

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

Keywords

FAQs

Package last updated on 28 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc