Files
llama.cpp/tools/ui/vite.config.ts
T
Aleksander Grygier d1c4e5bec1 ui: run local browser tests in installed Chrome with its sandbox on (#31596)
Playwright's bundled Chromium lags behind Chrome security releases
(1.56.1 ships 141, and even 1.64.1 ships 156.0.8078.4, before the
156.0.8078.73 fixes), and Playwright launches it with --no-sandbox by
default. Outside CI, use the installed, auto-updated Chrome with the
sandbox enabled. CI keeps the bundled Chromium, so the self-hosted
runner's preinstalled 1.56.1 browsers still work.

Assisted-by: Claude (Opus 5.5 Medium)
2026-11-03 19:02:54 +01:00

111 lines
3.0 KiB
TypeScript

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.constants';
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
import { sveltekit } from '@sveltejs/kit/vite';
import tailwindcss from '@tailwindcss/vite';
import { SvelteKitPWA } from '@vite-pwa/sveltekit';
import { playwright } from '@vitest/browser-playwright';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import { defineConfig, loadEnv, searchForWorkspaceRoot } from 'vite';
const __dirname = dirname(fileURLToPath(import.meta.url));
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const browserBaseConfig: any = {
enabled: true,
instances: [{ browser: 'chromium' }],
// CI runs the bundled Chromium without its sandbox, which the runners can't start;
// locally, the installed (auto-updated) Chrome with its sandbox on, see playwright.config.ts
provider: playwright({
launchOptions: process.env.CI
? { args: ['--no-sandbox'] }
: { channel: 'chrome', chromiumSandbox: true }
})
};
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), 'VITE_PUBLIC_');
const SERVER_ORIGIN = env.VITE_PUBLIC_SERVER_ORIGIN || 'http://localhost:9931';
return {
build: {
assetsInlineLimit: 32000,
chunkSizeWarningLimit: 3072,
minify: true
},
plugins: [
tailwindcss(),
sveltekit(),
SvelteKitPWA(SVELTEKIT_PWA_OPTIONS),
splashScreenPlugin(),
buildInfoPlugin(),
nerdamerPlugin(),
relativizeBasePlugin()
],
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
}
},
test: {
projects: [
{
extends: './vite.config.ts',
test: {
browser: browserBaseConfig,
include: ['tests/client/**/*.svelte.{test,spec}.{js,ts}'],
name: 'client',
setupFiles: ['./vitest-setup-client.ts']
}
},
{
extends: './vite.config.ts',
test: {
environment: 'node',
include: ['tests/unit/**/*.{test,spec}.{js,ts}'],
name: 'unit'
}
},
{
extends: './vite.config.ts',
plugins: [
storybookTest({
storybookScript: 'pnpm run storybook --no-open'
})
],
test: {
browser: { ...browserBaseConfig, instances: [{ browser: 'chromium', headless: true }] },
name: 'ui'
}
}
]
}
};
});