ci(web): typecheck/lint/test/build + bundle-size budget
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
// Fails if the largest built JS entry chunk exceeds the gzipped budget.
|
||||
import { readdirSync, readFileSync } from "node:fs";
|
||||
import { gzipSync } from "node:zlib";
|
||||
import { join } from "node:path";
|
||||
|
||||
const BUDGET_KB = 150;
|
||||
const dir = "dist/assets";
|
||||
const jsFiles = readdirSync(dir).filter((f) => f.endsWith(".js"));
|
||||
let largest = 0;
|
||||
let largestName = "";
|
||||
for (const file of jsFiles) {
|
||||
const gz = gzipSync(readFileSync(join(dir, file))).length;
|
||||
if (gz > largest) { largest = gz; largestName = file; }
|
||||
}
|
||||
const kb = (largest / 1024).toFixed(1);
|
||||
console.log(`largest JS chunk: ${largestName} = ${kb} KB gz (budget ${BUDGET_KB} KB)`);
|
||||
if (largest > BUDGET_KB * 1024) {
|
||||
console.error(`bundle-size budget exceeded: ${kb} KB > ${BUDGET_KB} KB`);
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user