Skip to content

Commit

Permalink
feat(reporter): show gzip info for all compressible files
Browse files Browse the repository at this point in the history
  • Loading branch information
mojoaxel committed Mar 19, 2023
1 parent 47a0f4a commit 0378c91
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/vite/src/node/plugins/reporter.ts
Expand Up @@ -66,6 +66,11 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
)
})

const isCompressibleFile = (fileName: string): boolean =>
['html', 'json', 'svg', 'txt', 'xml', 'xhtml'].some((ext) =>
fileName.endsWith(`.${ext}`),
)

return {
name: 'vite:reporter',

Expand Down Expand Up @@ -149,9 +154,10 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
group: isCSS ? 'CSS' : 'Assets',
size: chunk.source.length,
mapSize: null, // Rollup doesn't support CSS maps?
compressedSize: isCSS
? await getCompressedSize(chunk.source)
: null,
compressedSize:
isCSS || isCompressibleFile(chunk.fileName)
? await getCompressedSize(chunk.source)
: null,
}
}
},
Expand Down

0 comments on commit 0378c91

Please sign in to comment.