char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Ilyaui: fix VITE_PUBLIC_SERVER variable reading (#24845)9c5531e2b

char/aliceai-t5-moe
2.7 KiB108 linesraw
1import { buildInfoPlugin } from './scripts/vite-plugin-build-info';
2import { nerdamerPlugin } from './scripts/vite-plugin-nerdamer';
3import { relativizeBasePlugin } from './scripts/vite-plugin-relativize-base';
4import { splashScreenPlugin } from './scripts/vite-plugin-splash-screen';
5import { SVELTEKIT_PWA_OPTIONS } from './src/lib/constants/pwa.constants';
6import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
7import { sveltekit } from '@sveltejs/kit/vite';
8import tailwindcss from '@tailwindcss/vite';
9import { SvelteKitPWA } from '@vite-pwa/sveltekit';
10import { playwright } from '@vitest/browser-playwright';
11import { dirname, resolve } from 'path';
12import { fileURLToPath } from 'url';
13import { defineConfig, loadEnv, searchForWorkspaceRoot } from 'vite';
14
15const __dirname = dirname(fileURLToPath(import.meta.url));
16// eslint-disable-next-line @typescript-eslint/no-explicit-any
17const browserBaseConfig: any = {
18	enabled: true,
19	instances: [{ browser: 'chromium' }],
20	provider: playwright({
21		launchOptions: {
22			args: ['--no-sandbox']
23		}
24	})
25};
26
27export default defineConfig(({ mode }) => {
28	const env = loadEnv(mode, process.cwd(), 'VITE_PUBLIC_');
29	const SERVER_ORIGIN = env.VITE_PUBLIC_SERVER_ORIGIN || 'http://localhost:8080';
30
31	return {
32		build: {
33			assetsInlineLimit: 32000,
34			chunkSizeWarningLimit: 3072,
35			minify: true
36		},
37
38		plugins: [
39			tailwindcss(),
40			sveltekit(),
41			SvelteKitPWA(SVELTEKIT_PWA_OPTIONS),
42			splashScreenPlugin(),
43			buildInfoPlugin(),
44			nerdamerPlugin(),
45			relativizeBasePlugin()
46		],
47
48		resolve: {
49			alias: {
50				'katex-fonts': resolve('node_modules/katex/dist/fonts')
51			}
52		},
53
54		server: {
55			fs: {
56				allow: [searchForWorkspaceRoot(process.cwd()), resolve(__dirname, 'tests')]
57			},
58			headers: {
59				'Cross-Origin-Embedder-Policy': 'require-corp',
60				'Cross-Origin-Opener-Policy': 'same-origin'
61			},
62			proxy: {
63				'/cors-proxy': SERVER_ORIGIN,
64				'/models': SERVER_ORIGIN,
65				'/props': SERVER_ORIGIN,
66				'/slots': SERVER_ORIGIN,
67				'/tools': SERVER_ORIGIN,
68				'/v1': SERVER_ORIGIN
69			}
70		},
71
72		test: {
73			projects: [
74				{
75					extends: './vite.config.ts',
76					test: {
77						browser: browserBaseConfig,
78						include: ['tests/client/**/*.svelte.{test,spec}.{js,ts}'],
79						name: 'client',
80						setupFiles: ['./vitest-setup-client.ts']
81					}
82				},
83
84				{
85					extends: './vite.config.ts',
86					test: {
87						environment: 'node',
88						include: ['tests/unit/**/*.{test,spec}.{js,ts}'],
89						name: 'unit'
90					}
91				},
92
93				{
94					extends: './vite.config.ts',
95					plugins: [
96						storybookTest({
97							storybookScript: 'pnpm run storybook --no-open'
98						})
99					],
100					test: {
101						browser: { ...browserBaseConfig, instances: [{ browser: 'chromium', headless: true }] },
102						name: 'ui'
103					}
104				}
105			]
106		}
107	};
108});