Files
insta-recipe/vite.config.ts
Giancarmine Salucci 8545744bb1 fix(ssr): resolve EventSource SSR violations and implement best practices
- Fix EventSource is not defined error in queue dashboard
- Add browser guards for all EventSource usage
- Replace static constants (EventSource.OPEN/CLOSED) with numeric values
- Fix setInterval SSR violation in LLM health indicator
- Replace $effect anti-pattern with onMount in share page
- Add comprehensive SvelteKit SSR best practices documentation
- Add SSR audit and testing verification

All changes follow SvelteKit best practices and are verified against
official documentation. Production build succeeds with no SSR errors.

Closes: FixEventSourceSSR
See: docs/outcomes/FixEventSourceSSR.md
2025-12-22 03:00:29 +01:00

88 lines
2.7 KiB
TypeScript

import tailwindcss from '@tailwindcss/vite';
import { defineConfig } from 'vitest/config';
import { playwright } from '@vitest/browser-playwright';
import { sveltekit } from '@sveltejs/kit/vite';
import { SvelteKitPWA } from '@vite-pwa/sveltekit';
import fs from 'fs';
export default defineConfig({
server: {
watch: {
ignored: ['**/debug_page.txt', '**/.ssl/**', '**/docs/**', '**/secrets/**']
},
https: {
key: fs.readFileSync('./.ssl/localhost.key'),
cert: fs.readFileSync('./.ssl/localhost.crt')
}
},
plugins: [
SvelteKitPWA({
srcDir: './src',
mode: 'development',
strategies: 'injectManifest',
filename: 'service-worker.ts',
scope: '/',
base: '/',
selfDestroying: process.env.SELF_DESTROYING_SW === 'true',
injectManifest: {
swSrc: 'src/service-worker.ts',
swDest: 'service-worker.js',
injectionPoint: 'self.__WB_MANIFEST'
},
manifest: {
short_name: 'InstaChef',
name: 'InstaChef Recipe Saver',
start_url: '/',
scope: '/',
display: 'standalone',
theme_color: "#ffffff",
background_color: "#ffffff",
icons: [
{ src: '/favicon.png', sizes: '192x192', type: 'image/png' },
{ src: '/favicon.png', sizes: '512x512', type: 'image/png' }
],
share_target: {
action: '/share',
method: 'GET',
enctype: 'application/x-www-form-urlencoded',
params: { title: 'title', text: 'text', url: 'url' }
}
},
workbox: {
globPatterns: ['client/**/*.{js,css,ico,png,svg,webp,woff,woff2}']
},
devOptions: {
enabled: true,
suppressWarnings: true,
navigateFallback: '/',
},
}),tailwindcss(), sveltekit()],
test: {
expect: { requireAssertions: true },
projects: [
{
extends: './vite.config.ts',
test: {
name: 'client',
browser: {
enabled: true,
provider: playwright(),
instances: [{ browser: 'chromium', headless: true }]
},
include: ['src/**/*.svelte.{test,spec}.{js,ts}'],
exclude: ['src/lib/server/**']
}
},
{
extends: './vite.config.ts',
test: {
name: 'server',
environment: 'node',
include: ['src/**/*.{test,spec}.{js,ts}'],
exclude: ['src/**/*.svelte.{test,spec}.{js,ts}']
}
}
]
}
});