To disambiguate in your webpack.config.js between development and production builds, you may use environment variables. The standard approach in Node.js modules can be applied: Set an environment variable when running webpack and refer to the variables using Node's process.env. The variable NODE_ENV is commonly used as de-facto standard (see here).
webpack.config.js
module.exports = {
plugins: [
new webpack.optimize.UglifyJsPlugin({
+ compress: process.env.NODE_ENV === 'production'
})
]
};
Use the cross-env package to cross-platform-set environment variables:
package.json
{
"scripts": {
"build": "cross-env NODE_ENV=production PLATFORM=web webpack"
}
}
© 2012–2016 Tobias Koppers
Licensed under the Creative Commons Attribution License 4.0.
https://webpack.js.org/guides/environment-variables/