Files
nxdns/web/vite.config.ts
T
mokhtar 4aaf6d3815 milestone 23: close the remaining codex findings
the vitest "something prevents Vite server from exiting" warning was
@stylexjs/unplugin, not our code: configureServer starts a 150ms polling
interval for HMR and clears it from server.httpServer's close event, which
vitest resolves to null in middleware mode. drop that one hook under VITEST
and keep the transform.

textMuted was swept rather than judged. measured against their grounds, the
39 flat text-zinc-500 sites went 4.12:1 -> 7.56:1 in dark mode, repairing a
WCAG AA failure, so that stands; the 4 already-adaptive sites went 7.40:1 ->
4.62:1 in light mode for nothing, so a textSecondary token restores their
original zinc-600/zinc-400 pair.

append the symbol families to the reset's font stack: Select renders U+25BE
and Segoe UI does not carry it.

correct two acceptance criteria that were literally false: both greps match
only comments.
2026-08-12 23:43:22 +02:00

55 lines
2.0 KiB
TypeScript

/// <reference types="vitest/config" />
import { fileURLToPath } from "node:url";
import stylex from "@stylexjs/unplugin";
import react from "@vitejs/plugin-react";
import { type Plugin, defineConfig } from "vite";
/**
* StyleX's Vite plugin polls its CSS store every 150ms from `configureServer`
* and pushes an HMR event when it changes. It clears that timer from the close
* event of `server.httpServer`. Vitest runs the dev server in middleware mode,
* where `httpServer` is null, so the timer is never cleared: the run finishes,
* the event loop stays awake, and vitest kills the worker after ten seconds with
* "something prevents Vite server from exiting". A test needs StyleX's
* transform, which is a different hook, and never needs its HMR — so drop this
* one hook under vitest and keep the plugin.
*
* Remove this once @stylexjs/unplugin clears the timer on `buildEnd` or guards
* the hook, and check that `npm test` still exits without the warning.
*/
function withoutDevServerPolling(plugin: Plugin | Plugin[]): Plugin[] {
return (Array.isArray(plugin) ? plugin : [plugin]).map(({ configureServer: _dropped, ...rest }) => rest);
}
function stylexPlugin(mode: string): Plugin | Plugin[] {
// StyleX resolves the `.stylex.ts` theme file itself, so it needs the `@`
// alias too — `resolve.alias` below is Vite's and the plugin cannot see it.
const configured = stylex.vite({
useCSSLayers: true,
dev: mode === "development",
runtimeInjection: false,
aliases: { "@/*": [fileURLToPath(new URL("./src/*", import.meta.url))] },
});
return process.env.VITEST === undefined ? configured : withoutDevServerPolling(configured);
}
export default defineConfig(({ mode }) => ({
plugins: [stylexPlugin(mode), react()],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
server: {
proxy: {
"/api": "http://127.0.0.1:8080",
"/metrics": "http://127.0.0.1:8080",
},
},
test: {
environment: "jsdom",
globals: true,
setupFiles: ["./vitest.setup.ts"],
},
}));