Two small infra changes to support visual verification of v0.3 phases
from a git worktree.
- vite.config.js. server.fs.allow extended to ["..", "../.."]. When
the dev server runs inside .worktrees/v0.3-tactile-quietware/ the
shared node_modules sits one extra directory up, which Vite's
default fs.strict policy rejected with HTTP 403 on the @sveltejs
runtime client. Allowing the parent path unblocks dev runs from
any worktree of this repo. No effect when dev runs from the main
checkout.
- scripts/capture-quietware-screenshots.mjs. Headless Playwright
driver that visits /design-system-v2 (and best-effort /) under
five attribute combinations (v0.2 baseline, quietware-dark,
quietware-light, quietware-hc-dark, quietware-hc-light) and
writes one PNG per combination to /tmp/lumotia-v0.3-screenshots/.
Used to email Jake the visual proof for Phase 4a review.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
82 lines
2.8 KiB
JavaScript
82 lines
2.8 KiB
JavaScript
// Using vitest/config rather than vite/config so one config surface drives
|
|
// `vite dev` / `vite build` AND `vitest run`. Vitest's defineConfig is a
|
|
// superset of Vite's — production builds ignore the `test` key.
|
|
import { defineConfig } from "vitest/config";
|
|
import { sveltekit } from "@sveltejs/kit/vite";
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
import { visualizer } from "rollup-plugin-visualizer";
|
|
|
|
// @ts-expect-error process is a nodejs global
|
|
const host = process.env.TAURI_DEV_HOST;
|
|
// @ts-expect-error process is a nodejs global
|
|
const analyze = process.env.ANALYZE === "1";
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig(async () => ({
|
|
plugins: [
|
|
sveltekit(),
|
|
tailwindcss(),
|
|
...(analyze
|
|
? [
|
|
visualizer({
|
|
filename: "reports/bundle-stats.html",
|
|
template: "treemap",
|
|
gzipSize: true,
|
|
brotliSize: true,
|
|
open: false,
|
|
}),
|
|
]
|
|
: []),
|
|
],
|
|
clearScreen: false,
|
|
server: {
|
|
port: 1420,
|
|
strictPort: true,
|
|
host: host || false,
|
|
hmr: host
|
|
? {
|
|
protocol: "ws",
|
|
host,
|
|
port: 1421,
|
|
}
|
|
: undefined,
|
|
watch: {
|
|
ignored: ["**/src-tauri/**"],
|
|
},
|
|
fs: {
|
|
// v0.3 Phase 4a screenshot capture: when dev server runs inside a
|
|
// git worktree (.worktrees/v0.3-tactile-quietware/) the parent
|
|
// node_modules sits one extra dir up. Allow the worktree root.
|
|
allow: ["..", "../.."],
|
|
},
|
|
},
|
|
test: {
|
|
// jsdom gives storage-shim tests a real localStorage / DOMException /
|
|
// window surface rather than hand-rolled mocks. Tests can override
|
|
// per-file with `// @vitest-environment node` if they need to.
|
|
environment: "jsdom",
|
|
// Discover *.test.{ts,js} colocated next to source. Mirrors Rust's
|
|
// #[cfg(test)] sibling convention; no separate tests/ tree.
|
|
include: ["src/**/*.{test,spec}.{ts,js}"],
|
|
// Frontend tests must never reach into the Tauri backend; that surface
|
|
// is owned by `cargo test` in src-tauri/ and crates/. v0.2 browser-mode
|
|
// component tests live under *.browser.{test,spec}.{ts,js,svelte} and
|
|
// are run by `npm run test:browser` against vitest.browser.config.js —
|
|
// exclude them from this jsdom suite so they don't double-run.
|
|
exclude: [
|
|
"src-tauri/**",
|
|
"node_modules/**",
|
|
"build/**",
|
|
".svelte-kit/**",
|
|
"src/**/*.browser.{test,spec}.{ts,js,svelte}",
|
|
],
|
|
// Restore a clean global state between tests — vitest's restoreMocks
|
|
// unwinds vi.spyOn / vi.fn, clearMocks resets call history, and
|
|
// unstubAllGlobals undoes vi.stubGlobal. Prevents accidental leakage
|
|
// when tests share modules with module-level state.
|
|
restoreMocks: true,
|
|
clearMocks: true,
|
|
unstubAllGlobals: true,
|
|
},
|
|
}));
|