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:
parent
a8dd136168
commit
d8f1690904
@ -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",
|
||||
|
@ -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: {
|
||||
|
Loading…
Reference in New Issue
Block a user