Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/plugin-vite/src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,23 @@ export function fresh(config?: FreshViteConfig): Plugin[] {
isDev = env.command === "serve";

return {
server: {
watch: {
// Ignore temp files, editor swap files, and Vite timestamp
// files. On Linux, these short-lived files can trigger a
// watchFs race condition in Deno where the watcher tries to
// open a file that has already been deleted, crashing the
// dev server with ENOENT.
ignored: [
"**/*.tmp.*",
"**/*.timestamp-*",
"**/*~",
"**/.#*",
"**/*.swp",
"**/*.swo",
],
},
},
esbuild: {
jsx: "automatic",
jsxImportSource: "preact",
Expand Down
26 changes: 26 additions & 0 deletions packages/plugin-vite/tests/config_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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("**/.#*");
});