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 be2b8fb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/vite/src/node/plugins/reporter.ts
Expand Up @@ -66,6 +66,12 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
)
})

const isCompressibleFile = (fileName: string): boolean =>
['css', 'html', 'js', 'json', 'svg', 'txt', 'xml', 'xhtml'].reduce<boolean>(
(isText, ext) => isText || fileName.endsWith(`.${ext}`),
false,
)

return {
name: 'vite:reporter',

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

0 comments on commit be2b8fb

Please sign in to comment.