Files
next-tjwater-frontend/scripts/verify-production-css.mjs
T
jiang bdf4436899
Generic Container CI/CD / test-build-publish (push) Successful in 1m48s
Frontend CI/CD / build-test-publish-and-deploy (push) Successful in 2m18s
fix: preserve backdrop filter in production
2026-08-17 20:22:35 +08:00

36 lines
1.3 KiB
JavaScript

import { readdir, readFile } from "node:fs/promises";
import { stdout } from "node:process";
import { fileURLToPath, URL } from "node:url";
import path from "node:path";
const assetsDirectory = fileURLToPath(new URL("../dist/assets/", import.meta.url));
const assetNames = await readdir(assetsDirectory);
const stylesheetName = assetNames.find((name) => /^index-.*\.css$/.test(name));
if (!stylesheetName) {
throw new Error("Production CSS verification failed: index stylesheet was not emitted.");
}
const stylesheet = await readFile(path.join(assetsDirectory, stylesheetName), "utf8");
const selector = ".agent-panel-shell.acrylic-panel";
const selectorOffset = stylesheet.indexOf(selector);
const ruleStart = stylesheet.indexOf("{", selectorOffset);
const ruleEnd = stylesheet.indexOf("}", ruleStart);
if (selectorOffset < 0 || ruleStart < 0 || ruleEnd < 0) {
throw new Error(`Production CSS verification failed: ${selector} rule is missing.`);
}
const declarations = stylesheet
.slice(ruleStart + 1, ruleEnd)
.split(";")
.map((declaration) => declaration.trim());
if (!declarations.some((declaration) => declaration.startsWith("backdrop-filter:"))) {
throw new Error(
"Production CSS verification failed: the standard backdrop-filter declaration was removed."
);
}
stdout.write(`Verified standard backdrop-filter in ${stylesheetName}.\n`);