test(frontend): cover the dev server's CSS prefixing

Nothing exercised the dev CSS path: CI's e2e run serves a production build,
and vitest.config.ts never loads vite.config.js, so dropping `css.transformer`
would leave every check green while Safari below 18.4 lost its blur again.

Drives the real config through Vite's programmatic server and asserts both the
standard and prefixed properties. Removing the transformer fails it.

Also trims the comment above the setting to the two lines the repo allows.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BEtFQ17BQDS52wXosTjcUU
This commit is contained in:
Sam Dornan
2026-09-18 01:03:27 +00:00
committed by Claude
parent 11d927a374
commit ff3cbce1e9
3 changed files with 37 additions and 7 deletions

View File

@@ -0,0 +1,30 @@
import path from "node:path";
import { createServer, type ViteDevServer } from "vite";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
// The dev server is the only place this is observable: CI's e2e run serves a
// production build, and vitest.config.ts never loads vite.config.js, so a
// dropped `css.transformer` would leave every other check green.
describe("dev server CSS", () => {
let server: ViteDevServer;
beforeAll(async () => {
server = await createServer({
configFile: path.resolve(process.cwd(), "vite.config.js"),
server: { middlewareMode: true },
logLevel: "error",
});
}, 60_000);
afterAll(async () => {
await server?.close();
});
it("generates vendor prefixes, not only on the build's minify path", async () => {
const result = await server.transformRequest(
"/test/fixtures/prefix-probe.css",
);
expect(result?.code).toMatch(/-webkit-backdrop-filter:\s*blur\(1px\)/);
expect(result?.code).toMatch(/[^-]backdrop-filter:\s*blur\(1px\)/);
});
});

View File

@@ -0,0 +1,5 @@
/* Probed by test/devCssPrefixing.test.ts. `backdrop-filter` needs a
`-webkit-` prefix below Safari 18.4, and the build targets cover it. */
.prefix-probe {
backdrop-filter: blur(1px);
}

View File

@@ -113,13 +113,8 @@ export default defineConfig(({ mode }) => {
hosts: ["localhost", "127.0.0.1", "romm.dev"],
}),
],
// Lightning CSS transforms dev and build alike, so the vendor prefixes it
// generates from Vite's baseline targets reach the dev server too. With
// Vite's default postcss transformer they only appear on the build's
// minify path, and Safari below 18.4 loses every backdrop-filter surface
// while developing. Never hand-write a `-webkit-` twin to paper over that:
// Lightning CSS keeps only the last of the pair, dropping the standard
// property from the bundle.
// Prefixes dev too, not just the build's minify path. Never hand-write a
// `-webkit-` twin: Lightning CSS keeps only the last of the pair.
css: {
transformer: "lightningcss",
},