Skip to content

Commit

Permalink
feat(reporter): show gzip info for all compressible files (fix #11288) (
Browse files Browse the repository at this point in the history
  • Loading branch information
mojoaxel committed Mar 23, 2023
1 parent ba45f92 commit 03502c8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/vite/src/node/plugins/reporter.ts
Expand Up @@ -20,6 +20,8 @@ type LogEntry = {
mapSize: number | null
}

const COMPRESSIBLE_ASSETS_RE = /\.(?:html|json|svg|txt|xml|xhtml)$/

export function buildReporterPlugin(config: ResolvedConfig): Plugin {
const compress = promisify(gzip)
const chunkLimit = config.build.chunkSizeWarningLimit
Expand Down Expand Up @@ -144,12 +146,14 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
} else {
if (chunk.fileName.endsWith('.map')) return null
const isCSS = chunk.fileName.endsWith('.css')
const isCompressible =
isCSS || COMPRESSIBLE_ASSETS_RE.test(chunk.fileName)
return {
name: chunk.fileName,
group: isCSS ? 'CSS' : 'Assets',
size: chunk.source.length,
mapSize: null, // Rollup doesn't support CSS maps?
compressedSize: isCSS
compressedSize: isCompressible
? await getCompressedSize(chunk.source)
: null,
}
Expand Down

0 comments on commit 03502c8

Please sign in to comment.