From 44d39783c4cab0b6afcfb1dbf5651ba805387ac7 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 18 Mar 2020 14:44:54 -0500 Subject: [PATCH 1/2] Group CSS files in shared build output separate from JS files --- packages/next/build/utils.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/next/build/utils.ts b/packages/next/build/utils.ts index c05917ecefd6ab8..65c354524175e37 100644 --- a/packages/next/build/utils.ts +++ b/packages/next/build/utils.ts @@ -204,9 +204,21 @@ export async function printTreeView( const sharedFiles = sizeData.sizeCommonFile messages.push(['+ shared by all', getPrettySize(sharedFilesSize), '']) - Object.keys(sharedFiles) + const sharedFileKeys = Object.keys(sharedFiles) + const sharedCssFiles: string[] = [] + ;[ + ...sharedFileKeys + .filter(file => { + if (file.endsWith('.css')) { + sharedCssFiles.push(file) + return false + } + return true + }) + .sort(), + ...sharedCssFiles.sort(), + ] .map(e => e.replace(buildId, '')) - .sort() .forEach((fileName, index, { length }) => { const innerSymbol = index === length - 1 ? '└' : '├' From 5d2c4c1e44b59b2737416f1ba7f258bad5cc52b6 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 18 Mar 2020 15:02:32 -0500 Subject: [PATCH 2/2] Fix buildId not being replaced in shared by all --- packages/next/build/utils.ts | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/next/build/utils.ts b/packages/next/build/utils.ts index 65c354524175e37..0873a731c4d0bd6 100644 --- a/packages/next/build/utils.ts +++ b/packages/next/build/utils.ts @@ -215,22 +215,21 @@ export async function printTreeView( } return true }) + .map(e => e.replace(buildId, '')) .sort(), - ...sharedCssFiles.sort(), - ] - .map(e => e.replace(buildId, '')) - .forEach((fileName, index, { length }) => { - const innerSymbol = index === length - 1 ? '└' : '├' - - const originalName = fileName.replace('', buildId) - const cleanName = getCleanName(originalName) - - messages.push([ - ` ${innerSymbol} ${cleanName}`, - prettyBytes(sharedFiles[originalName]), - '', - ]) - }) + ...sharedCssFiles.map(e => e.replace(buildId, '')).sort(), + ].forEach((fileName, index, { length }) => { + const innerSymbol = index === length - 1 ? '└' : '├' + + const originalName = fileName.replace('', buildId) + const cleanName = getCleanName(fileName) + + messages.push([ + ` ${innerSymbol} ${cleanName}`, + prettyBytes(sharedFiles[originalName]), + '', + ]) + }) console.log( textTable(messages, {