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

webpack-env

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-env

read variables from a .env.js file and make them available to webpack as globals

  • 0.7.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.8K
decreased by-12.58%
Maintainers
1
Weekly downloads
 
Created
Source

Webpack Env

Build Status

Webpack ENV is a webpack plug-in for creating ENV-variable-like globals in webpack.

Setup

First add Webpack Env as a webpack plug-in, using gulp this would look something like this:

//gulpfile.js
var gulp = require('gulp');
var webpack = require('webpack');
var webpackEnv = require('webpack-env');

gulp.task('webpack', function() {
  return gulp.src('./entry.js')
    .pipe(webpack({
      output: {
        filename: 'bundle.js'
      },
      plugins: [webpackEnv]
    }))
    .pipe(gulp.dest('build/'));
});

Create a .env.js file in the same directory as your gulpfile.js. This file should export an object that contains the eventual globals you want your webpack code to contain:

module.exports = {
  SOME_VAR: 'some val'
}

Multiple Environments

Weback Env also supports having multiple files for multiple environments. To create a set of Production environment globals, just create a .production_env.js file and run gulp with NODE_ENV set to 'production'.

Keep your secrets out of the repo

Be sure you've added all your .env files to your .gitignore.

Keywords

FAQs

Package last updated on 14 Oct 2015

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