Files
llama.cpp/tools/ui/vite.config.ts
T

104 lines
2.6 KiB
TypeScript
Raw Normal View History

2026-08-10 08:38:37 +02:00
import { buildInfoPlugin } from './scripts/vite-plugin-build-info';
import { nerdamerPlugin } from './scripts/vite-plugin-nerdamer';
import { relativizeBasePlugin } from './scripts/vite-plugin-relativize-base';
import { splashScreenPlugin } from './scripts/vite-plugin-splash-screen';
import { SVELTEKIT_PWA_OPTIONS } from './src/lib/constants/pwa';
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
2025-09-17 19:29:13 +02:00
import { sveltekit } from '@sveltejs/kit/vite';
2026-08-10 08:38:37 +02:00
import tailwindcss from '@tailwindcss/vite';
2026-06-12 15:53:26 +02:00
import { SvelteKitPWA } from '@vite-pwa/sveltekit';
2026-08-10 08:38:37 +02:00
import { playwright } from '@vitest/browser-playwright';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import { defineConfig, searchForWorkspaceRoot } from 'vite';
const __dirname = dirname(fileURLToPath(import.meta.url));
const SERVER_ORIGIN = import.meta.env?.VITE_PUBLIC_SERVER_ORIGIN || 'http://localhost:8080';
2026-06-04 16:23:08 +02:00
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const browserBaseConfig: any = {
enabled: true,
2026-08-10 08:38:37 +02:00
instances: [{ browser: 'chromium' }],
2026-06-04 16:23:08 +02:00
provider: playwright({
launchOptions: {
args: ['--no-sandbox']
}
2026-08-10 08:38:37 +02:00
})
2026-06-04 16:23:08 +02:00
};
export default defineConfig({
build: {
assetsInlineLimit: 32000,
chunkSizeWarningLimit: 3072,
minify: true
},
2026-06-12 15:53:26 +02:00
plugins: [
tailwindcss(),
sveltekit(),
SvelteKitPWA(SVELTEKIT_PWA_OPTIONS),
splashScreenPlugin(),
buildInfoPlugin(),
nerdamerPlugin(),
2026-06-12 15:53:26 +02:00
relativizeBasePlugin()
],
2026-08-10 08:38:37 +02:00
resolve: {
alias: {
'katex-fonts': resolve('node_modules/katex/dist/fonts')
}
},
server: {
fs: {
allow: [searchForWorkspaceRoot(process.cwd()), resolve(__dirname, 'tests')]
},
headers: {
'Cross-Origin-Embedder-Policy': 'require-corp',
'Cross-Origin-Opener-Policy': 'same-origin'
},
proxy: {
'/cors-proxy': SERVER_ORIGIN,
'/models': SERVER_ORIGIN,
'/props': SERVER_ORIGIN,
'/slots': SERVER_ORIGIN,
'/tools': SERVER_ORIGIN,
'/v1': SERVER_ORIGIN
}
},
2025-09-17 19:29:13 +02:00
test: {
projects: [
{
extends: './vite.config.ts',
test: {
2026-06-04 16:23:08 +02:00
browser: browserBaseConfig,
include: ['tests/client/**/*.svelte.{test,spec}.{js,ts}'],
2026-08-10 08:38:37 +02:00
name: 'client',
2025-09-17 19:29:13 +02:00
setupFiles: ['./vitest-setup-client.ts']
}
},
2025-09-17 19:29:13 +02:00
{
extends: './vite.config.ts',
test: {
environment: 'node',
2026-08-10 08:38:37 +02:00
include: ['tests/unit/**/*.{test,spec}.{js,ts}'],
name: 'unit'
2025-09-17 19:29:13 +02:00
}
},
2025-09-17 19:29:13 +02:00
{
extends: './vite.config.ts',
plugins: [
storybookTest({
storybookScript: 'pnpm run storybook --no-open'
})
2026-08-10 08:38:37 +02:00
],
test: {
browser: { ...browserBaseConfig, instances: [{ browser: 'chromium', headless: true }] },
name: 'ui'
}
2025-09-17 19:29:13 +02:00
}
]
}
});