Files
OSIT-AE-App-Svelte/vite.config.ts
Scott Idem c750625e8f fix(build): roll back broken packages, pin tailwindcss 4.3.1 only
npm update (c4d4d2bde) silently upgraded @sveltejs/kit (2.53→2.66),
rollup (4.59→4.62), and svelte (5.53→5.56) together, which caused the
SSR production build to fail: rollup received raw .svelte files without
vite-plugin-svelte transforming them (non-deterministic, race condition).

Fix: restore stable package-lock from 468ed61b3, then selectively update
only tailwindcss and its ecosystem (4.2.1→4.3.1) to resolve DEP0205.
Align @tailwindcss/vite constraint to ^4.3.0 to match.

Also adds flowbite-svelte to optimizeDeps.exclude — it ships TypeScript
optional-param syntax in compiled .svelte dist files that esbuild rejects
during dependency pre-bundling (will matter when flowbite-svelte updates).

Build tested: npm run build ✔  |  svelte-check: 0 errors 0 warnings ✔

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-22 13:12:33 -04:00

45 lines
1.5 KiB
TypeScript

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';
}
}
}
}
}
});