55// the production page silently differs from the development server. vite.config.ts's cssTarget
66// keeps light-dark() native; this guards against that target being lowered again.
77//
8- // It also fails when a stylesheet outgrows its budget (gzipped): the shell's, which every page links
9- // and holds up its first paint for, and each of the others, a group of pages' or one that loads on
10- // demand (script/stylesheet-groups.ts).
8+ // It also fails when a stylesheet outgrows its budget (gzipped): the shell's, which every page but the
9+ // not-found page links and holds up its first paint for, the not-found page's, which it links alone,
10+ // and each of the others, a group of pages' or one that loads on demand (script/stylesheet-groups.ts).
1111// Run after `vite build`, optionally with the output directory: `bun script/check-css-output.ts .output`.
1212import path from "node:path"
1313import { Glob } from "bun"
1414
1515const root = path . resolve ( process . argv [ 2 ] ?? path . join ( import . meta. dir , ".." , ".output" ) , "public" )
16- const budgets = { shell : 27.5 * 1024 , other : 10.5 * 1024 }
16+ const budgets = { shell : 27.5 * 1024 , notFound : 26 * 1024 , other : 10.5 * 1024 }
1717const lowered : string [ ] = [ ]
1818const over : string [ ] = [ ]
1919const shells : string [ ] = [ ]
@@ -24,7 +24,8 @@ for await (const file of new Glob("**/*.css").scan(root)) {
2424 const shell = path . basename ( file ) . startsWith ( "shell-" )
2525 if ( shell ) shells . push ( file )
2626 const size = Bun . gzipSync ( css , { level : 9 } ) . length
27- const budget = shell ? budgets . shell : budgets . other
27+ const notFound = path . basename ( file ) . startsWith ( "not-found-" )
28+ const budget = shell ? budgets . shell : notFound ? budgets . notFound : budgets . other
2829 if ( size > budget ) over . push ( `${ file } ${ ( size / 1024 ) . toFixed ( 1 ) } kB (budget ${ ( budget / 1024 ) . toFixed ( 1 ) } kB)` )
2930}
3031if ( lowered . length > 0 ) {
0 commit comments