diff --git a/frontend/test/devCssPrefixing.test.ts b/frontend/test/devCssPrefixing.test.ts new file mode 100644 index 000000000..afc7e1dc5 --- /dev/null +++ b/frontend/test/devCssPrefixing.test.ts @@ -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\)/); + }); +}); diff --git a/frontend/test/fixtures/prefix-probe.css b/frontend/test/fixtures/prefix-probe.css new file mode 100644 index 000000000..c68eb67ad --- /dev/null +++ b/frontend/test/fixtures/prefix-probe.css @@ -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); +} diff --git a/frontend/vite.config.js b/frontend/vite.config.js index fe971f7d3..6d36eb58c 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -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", },