[webpack] set up proper dev/prod environment (#916)

This commit is contained in:
Maxime Beauchemin 2016-08-10 15:02:01 -07:00 committed by GitHub
parent baf22c3c60
commit 08d682501e
2 changed files with 13 additions and 3 deletions

View File

@ -8,8 +8,8 @@
},
"scripts": {
"test": "npm run lint && mocha --compilers js:babel-core/register --required spec/helpers/browser.js spec/**/*_spec.*",
"dev": "webpack -d --watch --colors",
"prod": "webpack -p --colors",
"dev": "NODE_ENV=dev webpack -d --watch --colors",
"prod": "NODE_ENV=production webpack -p --colors",
"lint": "npm run --silent lint:js",
"lint:js": "eslint --ignore-path=.eslintignore --ext .js ."
},

View File

@ -1,3 +1,4 @@
const webpack = require('webpack');
const path = require('path');
// input dir
@ -104,6 +105,15 @@ const config = {
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': true,
},
plugins: [],
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
},
}),
],
};
if (process.env.NODE_ENV === 'production') {
config.plugins.push(new webpack.optimize.UglifyJsPlugin());
}
module.exports = config;