Stop dev-server full reloads when test files are saved

Once anything requests a test module through the Vite dev server it joins
the client module graph, and every later save of that file dead-ends HMR
into a full page reload broadcast to all connected clients. With parallel
agents saving test files continuously, the dev UI reloaded out from under
interactive sessions every few seconds during bursts (31k+ reloads in the
hot-dev log), which read as "tabs sometimes don't load when clicked".

Ignore test files in the dev watcher, scoped off vitest's test mode so
watch-mode re-runs still see changes. Verified live: test-file touch no
longer reloads a connected page, source HMR unaffected, vitest run green.
This commit is contained in:
rcourtman
2026-07-10 11:09:40 +01:00
parent f356994869
commit ef19e64b28
+11 -2
View File
@@ -45,7 +45,7 @@ const proxyOriginOverride = process.env.PULSE_DEV_PROXY_ORIGIN ?? '';
const srcAlias = path.resolve(__dirname, './src');
export default defineConfig({
export default defineConfig(({ mode }) => ({
plugins: [solid(), sri({ algorithm: 'sha384' })],
resolve: {
alias: {
@@ -57,6 +57,15 @@ export default defineConfig({
port: frontendDevPort,
host: frontendDevHost,
strictPort: true,
// Test files are not part of the client app, but once anything requests
// one through the dev server it enters the client module graph, and every
// later save of it dead-ends HMR into a full page reload for all connected
// clients. Parallel agents save test files constantly, so ignore them in
// the dev watcher. Scoped off test mode so vitest watch re-runs still see
// file changes.
...(mode === 'test'
? {}
: { watch: { ignored: ['**/__tests__/**', '**/*.test.ts', '**/*.test.tsx'] } }),
proxy: {
'/ws': {
target: backendWsUrl,
@@ -284,4 +293,4 @@ export default defineConfig({
'**/tests/integration/**',
],
},
});
}));