diff --git a/package.json b/package.json index b8b36936..699254c9 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,8 @@ "start-dev": "npm-run-all --parallel watch start", "build": "npm-run-all build:*", "build:font-awesome": "node scripts/build-fontawesome.js", - "build:webpack": "webpack", - "watch": "webpack -w", + "build:webpack": "webpack -p", + "watch": "webpack -d --watch", "test": "npm-run-all -c test:* lint", "test:mocha": "mocha", "lint": "npm-run-all -c lint:*", diff --git a/webpack.config.js b/webpack.config.js index a09897ce..55f820d2 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,11 +2,12 @@ const webpack = require("webpack"); const path = require("path"); +const isWatch = process.argv.includes("--watch"); -module.exports = { +let config = { entry: { - app: path.resolve(__dirname, "client/js/lounge.js"), - vendor: [ + "js/bundle.js": path.resolve(__dirname, "client/js/lounge.js"), + "js/bundle.vendor.js": [ "handlebars/runtime", "jquery", "jquery-ui/ui/widgets/sortable", @@ -17,8 +18,8 @@ module.exports = { }, devtool: "source-map", output: { - path: path.resolve(__dirname, "client/js"), - filename: "bundle.js", + path: path.resolve(__dirname, "client"), + filename: "[name]", publicPath: "/" }, module: { @@ -53,14 +54,18 @@ module.exports = { ] }, plugins: [ - new webpack.optimize.CommonsChunkPlugin( - "vendor", // chunkName - "bundle.vendor.js" // filename - ), - new webpack.optimize.UglifyJsPlugin({ - compress: { - warnings: false - } - }), + new webpack.optimize.DedupePlugin(), + new webpack.optimize.CommonsChunkPlugin("js/bundle.vendor.js"), ] }; + +if (!isWatch) { + config.plugins.push(new webpack.optimize.UglifyJsPlugin({ + comments: false, + compress: { + warnings: false + } + })); +} + +module.exports = config;