Skip to content

Commit

Permalink
fix: gzip and calculate. (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
wattanx authored Aug 12, 2024
1 parent 7b78ae2 commit d13d137
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/vite/report.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fsp from 'node:fs/promises';
import { globby } from 'globby';
import { join } from 'pathe';
import zlib from 'zlib';
import { getOptions } from '../utils';

export async function getClientStats() {
Expand All @@ -24,7 +25,7 @@ async function analyzeSizes(pattern: string | string[], rootDir: string) {
)?.isSymbolicLink();

if (!isSymlink) {
const bytes = Buffer.byteLength(await fsp.readFile(path));
const bytes = zlib.gzipSync(await fsp.readFile(path)).byteLength;
totalBytes += bytes;
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports[`ts test > Vite comparison results test 1`] = `
# Bundle Size
| Route | Size (gzipped) |
| --- | --- |
| \`app\` | 155.83 kB (🔴 55.83 kB) |
| \`app\` | 60.14 kB (🟢 -39.86 kB) |
| \`pages/index\` | removed |
| \`components/tutorial\` | removed |
| \`pages/test\` | removed |"
Expand Down

0 comments on commit d13d137

Please sign in to comment.