All Projects β†’ sindresorhus β†’ Node Env Webpack Plugin

sindresorhus / Node Env Webpack Plugin

Licence: mit
Simplified `NODE_ENV` handling with webpack

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Node Env Webpack Plugin

Add Asset Webpack Plugin
Dynamically add an asset to the Webpack graph
Stars: ✭ 84 (+64.71%)
Mutual labels:  webpack, webpack-plugin, npm-package
Bundlephobia
πŸ‹οΈ Find out the cost of adding a new frontend dependency to your project
Stars: ✭ 6,640 (+12919.61%)
Mutual labels:  webpack, npm-package
Duplicate Package Checker Webpack Plugin
πŸ•΅οΈ Webpack plugin that warns you when a build contains multiple versions of the same package
Stars: ✭ 635 (+1145.1%)
Mutual labels:  webpack, webpack-plugin
Cloudflare Workers Webpack Plugin
Launch Cloudflare Workers to the Edge from the comfort of your build step πŸš€
Stars: ✭ 18 (-64.71%)
Mutual labels:  webpack, webpack-plugin
Optimize Plugin
Optimized Webpack Bundling for Everyone. Intro ‡️
Stars: ✭ 525 (+929.41%)
Mutual labels:  webpack, webpack-plugin
Webpack Config Plugins
Provide best practices for webpack loader configurations
Stars: ✭ 529 (+937.25%)
Mutual labels:  webpack, webpack-plugin
Prerender Spa Plugin
Prerenders static HTML in a single-page application.
Stars: ✭ 7,018 (+13660.78%)
Mutual labels:  webpack, webpack-plugin
Webpack Parallel Uglify Plugin
A faster uglifyjs plugin.
Stars: ✭ 456 (+794.12%)
Mutual labels:  webpack, webpack-plugin
Event Hooks Webpack Plugin
Event hooks plugin for webpack
Stars: ✭ 30 (-41.18%)
Mutual labels:  webpack, webpack-plugin
Express React Boilerplate
πŸš€πŸš€πŸš€ This is a tool that helps programmers create Express & React projects easily base on react-cool-starter.
Stars: ✭ 32 (-37.25%)
Mutual labels:  webpack, npm-package
Webpack Alioss Plugin
ι˜Ώι‡Œ oss-webpack θ‡ͺεŠ¨δΈŠδΌ ζ’δ»Ά
Stars: ✭ 35 (-31.37%)
Mutual labels:  webpack, webpack-plugin
Html Inline Css Webpack Plugin
β˜„οΈ A webpack plugin for convert external stylesheet to the embedded stylesheet
Stars: ✭ 48 (-5.88%)
Mutual labels:  webpack, webpack-plugin
Babel Minify Webpack Plugin
[DEPRECATED] Babel Minify Webpack Plugin
Stars: ✭ 502 (+884.31%)
Mutual labels:  webpack, webpack-plugin
Webpack Deep Scope Analysis Plugin
A webpack plugin for deep scope analysis
Stars: ✭ 589 (+1054.9%)
Mutual labels:  webpack, webpack-plugin
Offline Plugin
Offline plugin (ServiceWorker, AppCache) for webpack (https://webpack.js.org/)
Stars: ✭ 4,444 (+8613.73%)
Mutual labels:  webpack, webpack-plugin
Error Overlay Webpack Plugin
Catch errors with style πŸ’₯✨
Stars: ✭ 821 (+1509.8%)
Mutual labels:  webpack, webpack-plugin
Dotenv Webpack
A secure webpack plugin that supports dotenv and other environment variables and only exposes what you choose and use.
Stars: ✭ 1,022 (+1903.92%)
Mutual labels:  webpack, webpack-plugin
Webpack Chrome Extension Reloader
πŸ”₯ Hot reloading while developing Chrome extensions with webpack πŸ”₯
Stars: ✭ 365 (+615.69%)
Mutual labels:  webpack, webpack-plugin
Moment Locales Webpack Plugin
Easily remove unused Moment.js locales with webpack
Stars: ✭ 396 (+676.47%)
Mutual labels:  webpack, webpack-plugin
Webpack Common Shake
CommonJS Tree Shaker plugin for WebPack
Stars: ✭ 875 (+1615.69%)
Mutual labels:  webpack, webpack-plugin

node-env-webpack-plugin Build Status

Simplified NODE_ENV handling with webpack

Install

$ npm install node-env-webpack-plugin

Usage

  'use strict';
  const path = require('path');
+ const NodeEnvPlugin = require('node-env-webpack-plugin');

- const NODE_ENV = process.env.NODE_ENV || 'development';
- const isProduction = NODE_ENV === 'production';

  module.exports = {
  	entry: './source',
  	output: {
  		path: path.join(__dirname, 'distribution'),
  		filename: 'bundle.js'
  	},
- 	devtool: isProduction ? 'source-map' : 'cheap-module-source-map',
+ 	devtool: NodeEnvPlugin.devtool,
  	module: {
  		rules: [
  			{
  				test: /\.js$/,
  				exclude: /node_modules/,
  				loader: 'babel-loader'
  			}
  		]
  	},
  	plugins: [
- 		new webpack.EnvironmentPlugin({
- 			NODE_ENV: 'development'
- 		}),
+ 		new NodeEnvPlugin()
  	]
  };

API

Sets process.env.NODE_ENV in the Node.js process to development at import-time if it's not defined, or production if webpack is run with webpack -p.

NodeEnvPlugin()

Sets process.env.NODE_ENV in the bundle to the same as in the Node.js process.

NodeEnvPlugin.isProduction

For convenience and to prevent typos.

process.env.NODE_ENV === 'production'

NodeEnvPlugin.isDevelopment

process.env.NODE_ENV === 'development'

NodeEnvPlugin.isTest

process.env.NODE_ENV === 'test'

NodeEnvPlugin.devtool

Pass this to the webpack devtool option. It will give you good but slow source maps in production (source-map) and fast source maps in development (cheap-module-source-map).

Related

License

MIT Β© Sindre Sorhus

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].