-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathvite.config.ts
More file actions
75 lines (67 loc) · 1.96 KB
/
vite.config.ts
File metadata and controls
75 lines (67 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { sveltekit } from '@sveltejs/kit/vite';
import houdini from 'houdini/vite';
import { defineConfig } from 'vitest/config';
import { paraglideVitePlugin } from '@inlang/paraglide-js';
import tailwindcss from '@tailwindcss/vite';
import { sentrySvelteKit } from '@sentry/sveltekit';
function devAutoRestart() {
const RACE_CONDITION_PATTERNS = [
'has not been implemented', // Pothos ObjectRef race condition
'Class extends value undefined is not a constructor or null' // Houdini store race condition
];
return {
name: 'dev-auto-restart',
configureServer(server) {
let restarting = false;
const triggerRestart = (label) => {
if (restarting) return;
restarting = true;
console.warn(`\n⚠️ ${label}, restarting dev server...\n`);
server.restart();
};
const isRaceCondition = (message) =>
RACE_CONDITION_PATTERNS.some((pattern) => message?.includes(pattern));
const onUnhandledRejection = (reason) => {
if (reason instanceof Error && isRaceCondition(reason.message)) {
triggerRestart('Race condition detected');
}
};
process.on('unhandledRejection', onUnhandledRejection);
server.httpServer?.on('close', () => {
process.off('unhandledRejection', onUnhandledRejection);
});
const originalSsrFixStacktrace = server.ssrFixStacktrace;
server.ssrFixStacktrace = function (e) {
originalSsrFixStacktrace.call(this, e);
if (isRaceCondition(e?.message)) {
triggerRestart('SSR race condition detected');
}
};
}
};
}
export default defineConfig({
plugins: [
devAutoRestart(),
sentrySvelteKit({
autoUploadSourceMaps: false // We upload manually via CI to Bugsink
}),
tailwindcss(),
houdini(),
sveltekit(),
paraglideVitePlugin({
project: './project.inlang',
outdir: './src/lib/paraglide',
strategy: ['url', 'baseLocale']
})
],
build: {
sourcemap: true // Required for Bugsink error tracking
},
test: {
environment: 'jsdom',
coverage: {
provider: 'v8'
}
}
});