# babel-plugin-inline-dotenv

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

Latest version **1.7.0** (published 2022-03-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-inline-dotenv
pnpm add babel-plugin-inline-dotenv
yarn add babel-plugin-inline-dotenv
bun add babel-plugin-inline-dotenv
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.7.0 |
| Published | 2022-03-28 |
| First published | 2016-08-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 54.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 123 |
| Author | Bryan Goldstein |
| Maintainers | brysgo1 |
| Keywords | babel, plugin, dotenv |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-inline-dotenv
- Repository: https://github.com/brysgo/babel-plugin-inline-dotenv
- Homepage: https://github.com/brysgo/babel-plugin-inline-dotenv#readme
- Issues: https://github.com/brysgo/babel-plugin-inline-dotenv/issues
- npm.io page: https://npm.io/package/babel-plugin-inline-dotenv

## Dependencies (1)

- [dotenv](https://npm.io/package/dotenv.md) ^16.0.0

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.7.0 (latest) — 2022-03-28
- 1.6.0 — 2020-07-23
- 1.5.0 — 2019-08-30
- 1.4.0 — 2019-08-30
- 1.3.3 — 2019-05-03
- 1.3.2 — 2019-05-03
- 1.3.1 — 2019-04-07
- 1.3.0 — 2019-03-30
- 1.2.2 — 2019-03-14
- 1.2.1 — 2019-01-30
- 1.2.0 — 2018-11-15
- 1.1.2 — 2017-12-19
- 1.1.1 — 2016-08-29
- 1.1.0 — 2016-08-29
- 1.0.1 — 2016-08-27
- … 1 more at https://npm.io/package/babel-plugin-inline-dotenv/versions

## README

# babel-plugin-inline-dotenv

![Test](https://github.com/brysgo/babel-plugin-inline-dotenv/workflows/Test/badge.svg)

[![npm package](https://nodei.co/npm/babel-plugin-inline-dotenv.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/babel-plugin-inline-dotenv/)


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

```sh
$ npm install babel-plugin-inline-dotenv
```

## Usage

### Via `.babelrc` (Recommended)

Without options:

**.babelrc**

```js
{
  "plugins": ["inline-dotenv"]
}
```

With options:

```js
{
  "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:

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

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

```js
{
  "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

```sh
$ babel --plugins inline-dotenv script.js
```

### Via Node API

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

---
_Source: https://npm.io/package/babel-plugin-inline-dotenv · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
