my website at ewancroft.uk

fix(build): resolve manualChunks error for server-side dependencies

- Change manualChunks from object to function to handle SSR externals
- Only chunk client-side libraries (lucide, hls.js)
- Exclude @atproto/api from optimization as it's server-side only
- Let Vite automatically handle other vendor chunking

ewancroft.uk ae89dcfe 326d1bc3

verified
Changed files
+21 -7
+21 -7
vite.config.ts
··· 9 9 // Optimize chunk splitting for better caching 10 10 rollupOptions: { 11 11 output: { 12 - manualChunks: { 13 - // Split vendor code into separate chunks 14 - 'atproto': ['@atproto/api'], 15 - 'lucide': ['@lucide/svelte'], 16 - 'hls': ['hls.js'] 12 + manualChunks: (id) => { 13 + // Only chunk client-side code, not SSR externals 14 + if (id.includes('node_modules')) { 15 + // Lucide icons - client-side only 16 + if (id.includes('@lucide/svelte')) { 17 + return 'lucide'; 18 + } 19 + // HLS.js - client-side only 20 + if (id.includes('hls.js')) { 21 + return 'hls'; 22 + } 23 + // Other vendor code 24 + return 'vendor'; 25 + } 17 26 } 18 27 } 19 28 }, ··· 30 39 }, 31 40 32 41 optimizeDeps: { 33 - include: ['@atproto/api', '@lucide/svelte', 'hls.js'], 34 - exclude: [] 42 + include: ['@lucide/svelte', 'hls.js'], 43 + exclude: ['@atproto/api'] 35 44 }, 36 45 37 46 server: { ··· 39 48 fs: { 40 49 strict: true 41 50 } 51 + }, 52 + 53 + ssr: { 54 + // Don't externalize these in SSR 55 + noExternal: [] 42 56 } 43 57 });