# webpack-dotenv-plugin

> Use dotenv with webpack.

Latest version **2.1.0** (published 2018-07-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install webpack-dotenv-plugin
pnpm add webpack-dotenv-plugin
yarn add webpack-dotenv-plugin
bun add webpack-dotenv-plugin
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2018-07-16 |
| First published | 2016-05-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/webpack-dotenv-plugin) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 53 |
| Author | Nathan Winch |
| Maintainers | nwinch |
| Keywords | webpack, dotenv, dot, env, environment, variables, plugin |

## Links

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

## Dependencies (1)

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

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 2.1.0 (latest) — 2018-07-16
- 2.0.2 — 2017-06-21
- 2.0.0 — 2017-02-01
- 1.4.0 — 2016-10-18
- 1.3.2 — 2016-06-07
- 1.3.1 — 2016-06-07
- 1.3.0 — 2016-06-07
- 1.2.0 — 2016-05-27
- 1.1.0 — 2016-05-23
- 1.0.0 — 2016-05-18

## README

# Webpack dotenv plugin

Use dotenv with webpack.

## Motivation

[`dotenv`](https://github.com/bkeepers/dotenv) is a fantastic and useful way to
manage environment variables. I wanted to keep the good times going when
working with webpack for frontend projects.

## Install

```
npm i --save-dev webpack-dotenv-plugin
```

## Usage

`webpack-dotenv-plugin` uses [`dotenv-safe`](https://github.com/rolodato/dotenv-safe)
under the hood to read and check environment variables. The same options that
can be passed to `dotenv-safe` can be passed to this plugin.

It then reads, parses and exports the listed env vars from `.env` into
stringified `process.env` so it can be bundled for use with webpack.

Externally set environment variables will override vars set in `.env`.

```js
// webpack.config.js
const DotenvPlugin = require('webpack-dotenv-plugin');

module.exports = {
  ...
  plugins: [
    new DotenvPlugin({
      sample: './.env.default',
      path: './.env'
    })
  ]
  ...
};
```

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