sindresorhus / Node Env Webpack Plugin
Licence: mit
Simplified `NODE_ENV` handling with webpack
Stars: β 51
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
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
- add-asset-webpack-plugin - Dynamically add an asset to the webpack graph
-
add-module-exports-webpack-plugin - Add
module.exports
for Babel and TypeScript compiled code
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].