Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(reporter): show gzip info for all compressible files (fix #11288) #12485

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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