From acaef9f639315876ee23e146e8d6c40cb83ec8b2 Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Wed, 16 Dec 2015 10:33:58 +0100 Subject: [PATCH 1/3] Speed up npm bundle builds Use include option to point to app sources --- client/webpack.production.config.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/webpack.production.config.js b/client/webpack.production.config.js index 61c27fbda7..8cc287be0a 100644 --- a/client/webpack.production.config.js +++ b/client/webpack.production.config.js @@ -14,6 +14,8 @@ module.exports = { // fail on first error when building release bail: true, + cache: {}, + entry: { app: './app/scripts/main', 'terminal-app': './app/scripts/terminal-main' @@ -25,6 +27,9 @@ module.exports = { }, module: { + include: [ + path.resolve(__dirname, 'app/scripts') + ], preLoaders: [ { test: /\.js$/, From b70e68a3199e403cd8871025ef6b02399dadd67b Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Wed, 16 Dec 2015 13:45:37 +0100 Subject: [PATCH 2/3] Split JS bundle into vendor and app --- client/build/index.html | 1 + client/build/terminal.html | 1 + client/server.js | 2 +- client/webpack.local.config.js | 9 ++++++++- client/webpack.production.config.js | 5 ++++- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/client/build/index.html b/client/build/index.html index 17d2608eed..e4431f72d0 100644 --- a/client/build/index.html +++ b/client/build/index.html @@ -14,6 +14,7 @@
+ diff --git a/client/build/terminal.html b/client/build/terminal.html index 1e6133f0ce..f4846dec4c 100644 --- a/client/build/terminal.html +++ b/client/build/terminal.html @@ -14,6 +14,7 @@
+ diff --git a/client/server.js b/client/server.js index eec4c239b6..2bc6d768b0 100644 --- a/client/server.js +++ b/client/server.js @@ -19,7 +19,7 @@ var app = express(); // Serve application file depending on environment -app.get(/(app|terminal-app).js/, function(req, res) { +app.get(/(app|terminal-app|vendors).js/, function(req, res) { var filename = req.originalUrl; if (process.env.NODE_ENV === 'production') { res.sendFile(__dirname + '/build' + filename); diff --git a/client/webpack.local.config.js b/client/webpack.local.config.js index 17a5effc67..19416e1f58 100644 --- a/client/webpack.local.config.js +++ b/client/webpack.local.config.js @@ -32,7 +32,9 @@ module.exports = { './app/scripts/terminal-main', 'webpack-dev-server/client?http://localhost:4041', 'webpack/hot/only-dev-server' - ] + ], + vendors: ['classnames', 'd3', 'dagre', 'flux', 'immutable', + 'lodash', 'page', 'react', 'react-dom', 'react-motion'] }, // This will not actually create a app.js file in ./build. It is used @@ -45,12 +47,17 @@ module.exports = { // Necessary plugins for hot load plugins: [ + new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'), new webpack.HotModuleReplacementPlugin(), new webpack.NoErrorsPlugin() ], // Transform source code using Babel and React Hot Loader module: { + include: [ + path.resolve(__dirname, 'app/scripts') + ], + preLoaders: [ { test: /\.js$/, diff --git a/client/webpack.production.config.js b/client/webpack.production.config.js index 8cc287be0a..89744be46a 100644 --- a/client/webpack.production.config.js +++ b/client/webpack.production.config.js @@ -18,7 +18,9 @@ module.exports = { entry: { app: './app/scripts/main', - 'terminal-app': './app/scripts/terminal-main' + 'terminal-app': './app/scripts/terminal-main', + vendors: ['classnames', 'd3', 'dagre', 'flux', 'immutable', + 'lodash', 'page', 'react', 'react-dom', 'react-motion'] }, output: { @@ -70,6 +72,7 @@ module.exports = { plugins: [ new webpack.DefinePlugin(GLOBALS), + new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'), new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false From 57dfe4a4e8c9a1628851764d52ba2ad2ea8ec283 Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Wed, 16 Dec 2015 18:53:11 +0100 Subject: [PATCH 3/3] Dont use -p on webpack when declaring uglifyjs plugin --- client/package.json | 2 +- client/webpack.production.config.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/client/package.json b/client/package.json index e28cf37234..435b617d4a 100644 --- a/client/package.json +++ b/client/package.json @@ -58,7 +58,7 @@ "webpack-dev-server": "~1.12.1" }, "scripts": { - "build": "webpack -p --config webpack.production.config.js", + "build": "webpack --config webpack.production.config.js", "start": "node server.js", "start-production": "NODE_ENV=production node server.js", "test": "jest", diff --git a/client/webpack.production.config.js b/client/webpack.production.config.js index 89744be46a..a8a4d65769 100644 --- a/client/webpack.production.config.js +++ b/client/webpack.production.config.js @@ -73,7 +73,9 @@ module.exports = { plugins: [ new webpack.DefinePlugin(GLOBALS), new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'), + new webpack.optimize.OccurenceOrderPlugin(true), new webpack.optimize.UglifyJsPlugin({ + sourceMap: false, compress: { warnings: false }