From be2b8fbd533226fff274ad51a7b3de9b98b033a0 Mon Sep 17 00:00:00 2001 From: Alexander Wunschik Date: Sun, 19 Mar 2023 21:02:53 +0100 Subject: [PATCH] feat(reporter): show gzip info for all compressible files --- packages/vite/src/node/plugins/reporter.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/plugins/reporter.ts b/packages/vite/src/node/plugins/reporter.ts index 5b8ae593bdefea..070f0db044ebf8 100644 --- a/packages/vite/src/node/plugins/reporter.ts +++ b/packages/vite/src/node/plugins/reporter.ts @@ -66,6 +66,12 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin { ) }) + const isCompressibleFile = (fileName: string): boolean => + ['css', 'html', 'js', 'json', 'svg', 'txt', 'xml', 'xhtml'].reduce( + (isText, ext) => isText || fileName.endsWith(`.${ext}`), + false, + ) + return { name: 'vite:reporter', @@ -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, }