Skip to content

Commit

Permalink
[webpack] set up proper dev/prod environment (#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Aug 10, 2016
1 parent baf22c3 commit 08d6825
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions caravel/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ."
},
Expand Down
12 changes: 11 additions & 1 deletion caravel/assets/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const webpack = require('webpack');
const path = require('path');

// input dir
Expand Down Expand Up @@ -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;

0 comments on commit 08d6825

Please sign in to comment.