|
| 1 | +// vite.config.ts |
| 2 | + |
| 3 | +/// <reference types="vitest" /> |
| 4 | + |
1 | 5 | import tailwindcss from '@tailwindcss/vite'; |
2 | 6 | import { svelteTesting } from '@testing-library/svelte/vite'; |
3 | 7 | import { sveltekit } from '@sveltejs/kit/vite'; |
4 | 8 | import { defineConfig } from 'vite'; |
5 | 9 |
|
6 | | -export default defineConfig({ |
7 | | -plugins: [tailwindcss(), sveltekit()], |
8 | | -optimizeDeps: { |
9 | | -exclude: ['clsx', '@xyflow/system', 'classcat'] |
10 | | -}, |
11 | | -server: { |
12 | | -host: '0.0.0.0', |
13 | | -port: 3000 |
14 | | -}, |
15 | | -test: { |
16 | | -workspace: [ |
17 | | -{ |
18 | | -extends: './vite.config.ts', |
19 | | -plugins: [svelteTesting()], |
20 | | -test: { |
21 | | -name: 'client', |
22 | | -environment: 'jsdom', |
23 | | -clearMocks: true, |
24 | | -include: ['src/**/*.svelte.{test,spec}.{js,ts}'], |
25 | | -exclude: ['src/lib/server/**'], |
26 | | -setupFiles: ['./vitest-setup-client.ts'] |
27 | | -} |
28 | | -}, |
29 | | -{ |
30 | | -extends: './vite.config.ts', |
31 | | -test: { |
32 | | -name: 'server', |
33 | | -environment: 'node', |
34 | | -include: ['src/**/*.{test,spec}.{js,ts}'], |
35 | | -exclude: ['src/**/*.svelte.{test,spec}.{js,ts}'] |
| 10 | +const backendUrls = { |
| 11 | + development: 'http://localhost:5000', |
| 12 | + production: 'http://yourdomain.com' |
| 13 | +} as const; |
| 14 | + |
| 15 | +type BackendUrlMode = keyof typeof backendUrls; |
| 16 | + |
| 17 | + |
| 18 | +export default defineConfig(({ mode }) => { |
| 19 | + const safeMode = mode as BackendUrlMode; |
| 20 | + const backendUrl = backendUrls[safeMode] || backendUrls.production; |
| 21 | + |
| 22 | +return { |
| 23 | +plugins: [tailwindcss(), sveltekit()], |
| 24 | +optimizeDeps: { |
| 25 | +exclude: ['clsx', '@xyflow/system', 'classcat'] |
| 26 | +}, |
| 27 | +server: { |
| 28 | +host: '0.0.0.0', |
| 29 | +port: 3000, |
| 30 | + allowedHosts: [ |
| 31 | + 'localhost', |
| 32 | + '127.0.0.1', |
| 33 | + 'langgraph-gui.posetmage.com', |
| 34 | + ], |
| 35 | +}, |
| 36 | + define: { |
| 37 | + 'import.meta.env.VITE_BACKEND_URL': JSON.stringify(backendUrl) |
| 38 | + }, |
| 39 | +test: { |
| 40 | +workspace: [ |
| 41 | +{ |
| 42 | +extends: './vite.config.ts', |
| 43 | +plugins: [svelteTesting()], |
| 44 | +test: { |
| 45 | +name: 'client', |
| 46 | +environment: 'jsdom', |
| 47 | +clearMocks: true, |
| 48 | +include: ['src/**/*.svelte.{test,spec}.{js,ts}'], |
| 49 | +exclude: ['src/lib/server/**'], |
| 50 | +setupFiles: ['./vitest-setup-client.ts'] |
| 51 | +} |
| 52 | +}, |
| 53 | +{ |
| 54 | +extends: './vite.config.ts', |
| 55 | +test: { |
| 56 | +name: 'server', |
| 57 | +environment: 'node', |
| 58 | +include: ['src/**/*.{test,spec}.{js,ts}'], |
| 59 | +exclude: ['src/**/*.svelte.{test,spec}.{js,ts}'] |
| 60 | +} |
36 | 61 | } |
37 | | -} |
38 | | -] |
| 62 | +] |
| 63 | +} |
39 | 64 | } |
40 | | -}); |
| 65 | +}) |
0 commit comments