-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathvite.config.ts
More file actions
64 lines (58 loc) · 1.5 KB
/
vite.config.ts
File metadata and controls
64 lines (58 loc) · 1.5 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
// vite.config.ts
/// <reference types="vitest" />
import tailwindcss from '@tailwindcss/vite';
import { svelteTesting } from '@testing-library/svelte/vite';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
const backendUrls = {
development: 'http://localhost:5000',
production: 'http://yourdomain.com'
} as const;
type BackendUrlMode = keyof typeof backendUrls;
export default defineConfig(({ mode }) => {
const safeMode = mode as BackendUrlMode;
const backendUrl = backendUrls[safeMode] || backendUrls.production;
return {
plugins: [tailwindcss(), sveltekit()],
optimizeDeps: {
exclude: ['clsx', '@xyflow/system', 'classcat']
},
server: {
host: '0.0.0.0',
port: 3000,
allowedHosts: [
'localhost',
'127.0.0.1',
'yourdomain.com',
],
},
define: {
'import.meta.env.VITE_BACKEND_URL': JSON.stringify(backendUrl)
},
test: {
workspace: [
{
extends: './vite.config.ts',
plugins: [svelteTesting()],
test: {
name: 'client',
environment: 'jsdom',
clearMocks: true,
include: ['src/**/*.svelte.{test,spec}.{js,ts}'],
exclude: ['src/lib/server/**'],
setupFiles: ['./vitest-setup-client.ts']
}
},
{
extends: './vite.config.ts',
test: {
name: 'server',
environment: 'node',
include: ['src/**/*.{test,spec}.{js,ts}'],
exclude: ['src/**/*.svelte.{test,spec}.{js,ts}']
}
}
]
}
};
});