dotenv-webpack
A simple webpack plugin to support dotenv.
Status
Installation
Include the package locally in your repository.
npm install dotenv-webpack --save
Usage
The plugin can be installed with little-to-no configuration needed. Once installed, you can access the variables as expected within your code using process.env
.
The example bellow shows the defaults, as well as a description of each parameter.
// webpack.config.js
const Dotenv = require('dotenv-webpack');
module.exports = {
...
plugins: [
new Dotenv({
path: './.my.env', // if not simply .env
safe: true // lets load the .env.example file as well
})
]
...
};
Properties
Use the following properties to configure your instance.
- path (
'./env'
) - The path to your environment variables. - safe (
false
) - If false ignore safe-mode, if true load'./.env.example'
, if a string load that file as the sample. - systemvars (
false
) - Set to true if you would rather load all system variables as well (useful for CI purposes).
LICENSE
MIT