## Summary - Adds default `server.watch.ignored` patterns to the Fresh Vite plugin config - Ignores `*.tmp.*`, `*.timestamp-*`, editor swap files (`*.swp`, `*.swo`, `*~`, `.#*`) - Prevents a `watchFs` race condition on Linux where Deno tries to open a short-lived file that was already deleted, crashing the dev server with `NotFound: No such file or directory` Users can still override or extend these patterns in their own `vite.config.ts` since Vite merges config from plugins. Closes #3585 --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
27 lines
974 B
TypeScript
27 lines
974 B
TypeScript
import { expect } from "@std/expect";
|
|
import { fresh } from "../src/mod.ts";
|
|
import type { Plugin } from "vite";
|
|
|
|
Deno.test("fresh plugin - sets server.watch.ignored patterns", () => {
|
|
const plugins = fresh() as Plugin[];
|
|
const freshPlugin = plugins.find((p) => p.name === "fresh");
|
|
expect(freshPlugin).toBeDefined();
|
|
|
|
// Call the config hook as Vite would during dev
|
|
// deno-lint-ignore no-explicit-any
|
|
const configFn = freshPlugin!.config as any;
|
|
const result = configFn({}, { command: "serve" });
|
|
|
|
const ignored = result?.server?.watch?.ignored;
|
|
expect(ignored).toBeDefined();
|
|
expect(Array.isArray(ignored)).toBe(true);
|
|
|
|
// Should ignore temp files, editor swap files, and Vite timestamp files
|
|
expect(ignored).toContain("**/*.tmp.*");
|
|
expect(ignored).toContain("**/*.timestamp-*");
|
|
expect(ignored).toContain("**/*.swp");
|
|
expect(ignored).toContain("**/*.swo");
|
|
expect(ignored).toContain("**/*~");
|
|
expect(ignored).toContain("**/.#*");
|
|
});
|