Files
thebet365/apps/admin/scripts/report-chunk-sizes.mjs
Mars e7e938f261 feat: WC2026 赛事 seed、生产上线初始化脚本与目录归档
重构 seed 为 WC2026 72 场小组赛与 48 强优胜盘;新增 production 模式仅保留 admin 与赛事示例;提供 prod-init-db 全量重置脚本;管理端 i18n 分包与赛事归档能力。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-12 18:17:00 +08:00

33 lines
956 B
JavaScript

import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { gzipSync } from 'zlib';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const dist = path.join(__dirname, '../dist/assets');
if (!fs.existsSync(dist)) {
console.error('dist/assets not found — run pnpm build first');
process.exit(1);
}
const files = fs
.readdirSync(dist)
.filter((f) => f.endsWith('.js'))
.map((f) => {
const buf = fs.readFileSync(path.join(dist, f));
return {
file: f,
raw: buf.length,
gzip: gzipSync(buf).length,
};
})
.sort((a, b) => b.gzip - a.gzip);
console.log('Admin bundle chunk sizes (gzip):');
for (const row of files) {
console.log(`${(row.gzip / 1024).toFixed(1)} KB gzip ${(row.raw / 1024).toFixed(1)} KB raw ${row.file}`);
}
const totalGzip = files.reduce((s, r) => s + r.gzip, 0);
console.log(`\nTotal JS (all chunks): ${(totalGzip / 1024).toFixed(1)} KB gzip`);