From 9c2db29166bafd93e7247433e24f64446b2b3832 Mon Sep 17 00:00:00 2001 From: Sasha Aickin Date: Tue, 20 Jun 2017 21:27:24 -0700 Subject: [PATCH] Fixed an issue where two-page sites didn't split code. (#2329) --- server/build/webpack.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/build/webpack.js b/server/build/webpack.js index 6c814e4c..c01d07c6 100644 --- a/server/build/webpack.js +++ b/server/build/webpack.js @@ -102,7 +102,12 @@ export default async function createCompiler (dir, { dev = false, quiet = false, return module.context && module.context.indexOf('node_modules') >= 0 } - // Move modules used in at-least 1/2 of the total pages into commons. + // If there are one or two pages, only move modules to common if they are + // used in all of the pages. Otherwise, move modules used in at-least + // 1/2 of the total pages into commons. + if (totalPages <= 2) { + return count === totalPages + } return count >= totalPages * 0.5 } }),