From 8c98fbb5d34e6b959fdf1c875e4f8cc854ade8fb Mon Sep 17 00:00:00 2001 From: Sasha Aickin Date: Tue, 23 Feb 2016 08:30:06 -0800 Subject: [PATCH] Move common code out into a common chunk so that it can be separately cached. --- packages/react-server-cli/src/compileClient.js | 4 ++++ packages/react-server-cli/src/coreJsMiddleware.js | 1 + 2 files changed, 5 insertions(+) diff --git a/packages/react-server-cli/src/compileClient.js b/packages/react-server-cli/src/compileClient.js index 95e8b882e..dda2630e5 100644 --- a/packages/react-server-cli/src/compileClient.js +++ b/packages/react-server-cli/src/compileClient.js @@ -84,6 +84,10 @@ const packageCodeForBrowser = (entrypoints, outputDir, outputUrl, hot, minify) = }, plugins: [ new ExtractTextPlugin("[name].css"), + new webpack.optimize.CommonsChunkPlugin({ + name:"common", + filename: "common.js", + }), ], }; diff --git a/packages/react-server-cli/src/coreJsMiddleware.js b/packages/react-server-cli/src/coreJsMiddleware.js index 9a8b960f0..6dc76668e 100644 --- a/packages/react-server-cli/src/coreJsMiddleware.js +++ b/packages/react-server-cli/src/coreJsMiddleware.js @@ -4,6 +4,7 @@ export default (pathToStatic) => { const routeName = this.getRequest().getRouteName(); const baseUrl = pathToStatic || "/"; return [ + `${baseUrl}common.js`, `${baseUrl}${routeName}.bundle.js`, { type: "text/javascript",