import { defineConfig } from 'vite'; import { sveltekit } from '@sveltejs/kit/vite'; import tailwindcss from '@tailwindcss/vite'; export default defineConfig({ cacheDir: 'node_modules/.vite', plugins: [ tailwindcss(), sveltekit() // <-- Must come after Tailwind ], server: { watch: { // Do not trigger HMR/reload for documentation or test files ignored: ['**/documentation/**', '**/tests/**'] } }, optimizeDeps: { // flowbite-svelte ships TypeScript optional-param syntax (x?, date?) in its compiled // .svelte dist files. Esbuild's pre-bundler treats them as plain JS and rejects the `?` // syntax. Excluding it here lets vite-plugin-svelte handle it properly instead. // Re-evaluate if flowbite-svelte releases a clean JS dist (check when upgrading). exclude: ['@codemirror/*', 'flowbite-svelte'], include: [] }, ssr: { // Avoid forcing ESM conversion on large editor libs; let them be handled as-is noExternal: ['@codemirror/*'] }, build: { sourcemap: false, minify: 'esbuild', rollupOptions: { output: { // Keep all svelte internals in one chunk to prevent circular // dependency warnings between runtime.js and index-client.js manualChunks(id) { if (id.includes('/node_modules/svelte/')) { return 'svelte-vendor'; } } } } } });