返回 CodeWhale
site-css.ts
根目录 / web / lib / site-css.ts
1 import { readFileSync } from "node:fs";
2
3 /**
4 * The hand-written site stylesheet as one string, in cascade order.
5 *
6 * `app/globals.css` is an import hub; its rules live in `app/styles/*.css`.
7 * This inlines each `./styles/` import in place so the contract tests can read
8 * the stylesheet the way the browser resolves it. The generated `tokens.css`
9 * is left out, as it was before the split.
10 *
11 * Node-only (`node:fs`): imported by the contract tests, never by a component.
12 */
13 export function siteCss(): string {
14 const appDir = new URL("../app/", import.meta.url);
15 const hub = readFileSync(new URL("globals.css", appDir), "utf8");
16 return hub.replace(/^@import\s+"\.\/(styles\/[\w-]+\.css)";$/gm, (_, path: string) =>
17 readFileSync(new URL(path, appDir), "utf8"),
18 );
19 }
20
20 lines TYPESCRIPT