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

dotenv-webpack

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dotenv-webpack

A simple webpack plugin to support dotenv.

  • 6.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
389K
decreased by-59.81%
Maintainers
1
Weekly downloads
 
Created

What is dotenv-webpack?

The dotenv-webpack npm package is a plugin for webpack that automates the loading of environment variables from a .env file into process.env, providing an easy way to configure your application's environment-specific variables. It wraps dotenv and Webpack.DefinePlugin under the hood.

What are dotenv-webpack's main functionalities?

Load environment variables

Automatically loads environment variables from a .env file and makes them available in your application through process.env.

const Dotenv = require('dotenv-webpack');

module.exports = {
  //... other webpack config
  plugins: [
    new Dotenv()
  ]
  //... other webpack config
};

Custom .env file path

Allows you to specify a custom path to your .env file if it's not located in the root directory.

const Dotenv = require('dotenv-webpack');

module.exports = {
  //... other webpack config
  plugins: [
    new Dotenv({
      path: './some/other/path/.env'
    })
  ]
  //... other webpack config
};

Safe mode

Enables safe mode to ensure that all necessary environment variables are defined, by comparing with a template file (usually .env.example).

const Dotenv = require('dotenv-webpack');

module.exports = {
  //... other webpack config
  plugins: [
    new Dotenv({
      safe: true // load '.env.example' to check all necessary variables are defined
    })
  ]
  //... other webpack config
};

System variables

Allows the inclusion of system environment variables in the webpack build in addition to the variables from the .env file.

const Dotenv = require('dotenv-webpack');

module.exports = {
  //... other webpack config
  plugins: [
    new Dotenv({
      systemvars: true // load all system environment variables in addition to .env file
    })
  ]
  //... other webpack config
};

Other packages similar to dotenv-webpack

Keywords

FAQs

Package last updated on 04 Mar 2021

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