The previous session added flowbite-svelte to optimizeDeps.exclude to fix an esbuild TypeScript syntax error with 1.33.1. But tailwindcss 4.3+ is now stricter: when a style virtual module fails to load (which happens when the package is excluded from pre-bundling), tailwindcss receives the raw .svelte file content — including TypeScript — and rejects it with "Invalid declaration: Side". With flowbite-svelte 1.31.0, only Drawer and Modal are imported. Neither their dist files nor their transitive deps have TypeScript optional-param syntax (?: ) that would cause esbuild to fail. Safe to remove the exclusion. Updated the comment to explain when/why to re-add it if upgrading. Dev server: clean start, HTTP 200 ✔ | npm run build ✔ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
47 lines
1.7 KiB
TypeScript
47 lines
1.7 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: {
|
|
// @codemirror/* uses dynamic imports that confuse esbuild's pre-bundler; excluded here
|
|
// so vite-plugin-svelte handles them through the normal transform pipeline instead.
|
|
// flowbite-svelte: ONLY exclude if you upgrade to a version that ships TypeScript
|
|
// optional-param syntax (x?, date?) in its compiled dist files — verify with grep
|
|
// before adding it back. Excluding it causes tailwindcss 4.3+ to receive raw .svelte
|
|
// file content (including TypeScript) for style virtual modules, which it rejects.
|
|
exclude: ['@codemirror/*'],
|
|
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';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|