Use Webpack configuration based on NODE_ENV instead of watch/no-watch

Also, move the `DedupePlugin` to the prod-specific section. [Webpack doc](https://webpack.github.io/docs/list-of-plugins.html#dedupeplugin) itself recommends to not run this outside of production.

Note that this currently breaks cross-OS support of `npm run build`. This will be fixed in a latter commit.
This commit is contained in:
Jérémie Astori 2017-01-07 18:04:46 -05:00
parent a8dd136168
commit d8f1690904
2 changed files with 14 additions and 7 deletions

View file

@ -17,14 +17,14 @@
"start-dev": "npm-run-all --parallel watch start",
"build": "npm-run-all build:*",
"build:font-awesome": "node scripts/build-fontawesome.js",
"build:webpack": "webpack -p",
"watch": "webpack -d --watch",
"build:webpack": "webpack",
"watch": "webpack --watch",
"test": "npm-run-all -c test:* lint",
"test:mocha": "mocha",
"lint": "npm-run-all -c lint:*",
"lint:js": "eslint .",
"lint:css": "stylelint \"**/*.css\"",
"prepublish": "npm run build"
"prepublish": "NODE_ENV=production npm run build"
},
"keywords": [
"lounge",

View file

@ -2,7 +2,10 @@
const webpack = require("webpack");
const path = require("path");
const isWatch = process.argv.includes("--watch");
// ********************
// Common configuration
// ********************
let config = {
entry: {
@ -54,12 +57,16 @@ let config = {
]
},
plugins: [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.CommonsChunkPlugin("js/bundle.vendor.js"),
new webpack.optimize.CommonsChunkPlugin("js/bundle.vendor.js")
]
};
if (!isWatch) {
// *********************************
// Production-specific configuration
// *********************************
if (process.env.NODE_ENV === "production") {
config.plugins.push(new webpack.optimize.DedupePlugin());
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
comments: false,
compress: {