Skip to content

Commit

Permalink
Group CSS files in shared build output separate from JS files (#11184)
Browse files Browse the repository at this point in the history
* Group CSS files in shared build output separate from JS files

* Fix buildId not being replaced in shared by all
  • Loading branch information
ijjk committed Mar 19, 2020
1 parent 756b365 commit e28e8ad
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions packages/next/build/utils.ts
Expand Up @@ -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, '<buildId>'))
.sort()
.forEach((fileName, index, { length }) => {
const innerSymbol = index === length - 1 ? '└' : '├'

const originalName = fileName.replace('<buildId>', 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, '<buildId>'))
.sort(),
...sharedCssFiles.map(e => e.replace(buildId, '<buildId>')).sort(),
].forEach((fileName, index, { length }) => {
const innerSymbol = index === length - 1 ? '└' : '├'

const originalName = fileName.replace('<buildId>', buildId)
const cleanName = getCleanName(fileName)

messages.push([
` ${innerSymbol} ${cleanName}`,
prettyBytes(sharedFiles[originalName]),
'',
])
})

console.log(
textTable(messages, {
Expand Down

0 comments on commit e28e8ad

Please sign in to comment.