Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nwinch/webpack-dotenv-plugin
Use dotenv with webpack.
https://github.com/nwinch/webpack-dotenv-plugin
dotenv env environment-variables webpack
Last synced: 2 days ago
JSON representation
Use dotenv with webpack.
- Host: GitHub
- URL: https://github.com/nwinch/webpack-dotenv-plugin
- Owner: nwinch
- License: mit
- Created: 2016-05-18T09:40:52.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-16T11:40:38.000Z (over 6 years ago)
- Last Synced: 2024-12-06T08:46:53.648Z (about 1 month ago)
- Topics: dotenv, env, environment-variables, webpack
- Language: JavaScript
- Size: 11.7 KB
- Stars: 53
- Watchers: 2
- Forks: 17
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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'
})
]
...
};
```