diff --git a/package.json b/package.json index 699254c9..cdd0706f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/webpack.config.js b/webpack.config.js index 55f820d2..e2f4b094 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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: {