Created
January 23, 2017 15:44
-
-
Save nchase/087a49584ee04e454728804511f67697 to your computer and use it in GitHub Desktop.
Webpack EnvironmentPlugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Webpack's poorly-documented EnvironmentPlugin | |
// | |
// Read more here: https://github.com/webpack/webpack/blob/master/lib/EnvironmentPlugin.js | |
var webpack = require('webpack'); | |
module.exports = { | |
plugins: [ | |
new webpack.EnvironmentPlugin([ | |
'NODE_ENV' | |
]) | |
] | |
} |
Just wanted to thank you for this, I wonder why this is not more popular tho!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
with this, you should be able to pass your
NODE_ENV
to the webpack build process (e.g.NODE_ENV=production webpack
) and in your code, you can useprocess.env.NODE_ENV
to decide what to do differently based on the value ofNODE_ENV
.