From e28e8ada98462bc1d97093a6a4b764573a4032bf Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Thu, 19 Mar 2020 03:25:10 -0500 Subject: [PATCH] Group CSS files in shared build output separate from JS files (#11184) * Group CSS files in shared build output separate from JS files * Fix buildId not being replaced in shared by all --- packages/next/build/utils.ts | 41 +++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/packages/next/build/utils.ts b/packages/next/build/utils.ts index c05917ecefd6a..0873a731c4d0b 100644 --- a/packages/next/build/utils.ts +++ b/packages/next/build/utils.ts @@ -204,21 +204,32 @@ export async function printTreeView( const sharedFiles = sizeData.sizeCommonFile messages.push(['+ shared by all', getPrettySize(sharedFilesSize), '']) - Object.keys(sharedFiles) - .map(e => e.replace(buildId, '')) - .sort() - .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]), - '', - ]) - }) + const sharedFileKeys = Object.keys(sharedFiles) + const sharedCssFiles: string[] = [] + ;[ + ...sharedFileKeys + .filter(file => { + if (file.endsWith('.css')) { + sharedCssFiles.push(file) + return false + } + return true + }) + .map(e => e.replace(buildId, '')) + .sort(), + ...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, {