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",
|
"start-dev": "npm-run-all --parallel watch start",
|
||||||
"build": "npm-run-all build:*",
|
"build": "npm-run-all build:*",
|
||||||
"build:font-awesome": "node scripts/build-fontawesome.js",
|
"build:font-awesome": "node scripts/build-fontawesome.js",
|
||||||
"build:webpack": "webpack -p",
|
"build:webpack": "webpack",
|
||||||
"watch": "webpack -d --watch",
|
"watch": "webpack --watch",
|
||||||
"test": "npm-run-all -c test:* lint",
|
"test": "npm-run-all -c test:* lint",
|
||||||
"test:mocha": "mocha",
|
"test:mocha": "mocha",
|
||||||
"lint": "npm-run-all -c lint:*",
|
"lint": "npm-run-all -c lint:*",
|
||||||
"lint:js": "eslint .",
|
"lint:js": "eslint .",
|
||||||
"lint:css": "stylelint \"**/*.css\"",
|
"lint:css": "stylelint \"**/*.css\"",
|
||||||
"prepublish": "npm run build"
|
"prepublish": "NODE_ENV=production npm run build"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"lounge",
|
"lounge",
|
||||||
|
@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
const webpack = require("webpack");
|
const webpack = require("webpack");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const isWatch = process.argv.includes("--watch");
|
|
||||||
|
// ********************
|
||||||
|
// Common configuration
|
||||||
|
// ********************
|
||||||
|
|
||||||
let config = {
|
let config = {
|
||||||
entry: {
|
entry: {
|
||||||
@ -54,12 +57,16 @@ let config = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
plugins: [
|
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({
|
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
|
||||||
comments: false,
|
comments: false,
|
||||||
compress: {
|
compress: {
|
||||||
|
Loading…
Reference in New Issue
Block a user