my website at ewancroft.uk
1import tailwindcss from '@tailwindcss/vite';
2import { sveltekit } from '@sveltejs/kit/vite';
3import { defineConfig } from 'vite';
4
5export default defineConfig({
6 plugins: [tailwindcss(), sveltekit()],
7
8 build: {
9 // Optimize chunk splitting for better caching
10 rollupOptions: {
11 output: {
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 }
26 }
27 }
28 },
29 // Target modern browsers for smaller bundle size
30 target: 'es2022',
31 // Enable minification
32 minify: 'esbuild',
33 // Source maps for production debugging (set to false to reduce bundle size)
34 sourcemap: false,
35 // CSS code splitting
36 cssCodeSplit: true,
37 // Chunk size warnings
38 chunkSizeWarningLimit: 1000
39 },
40
41 optimizeDeps: {
42 include: ['@lucide/svelte', 'hls.js', '@atproto/api']
43 },
44
45 server: {
46 // Development server configuration
47 fs: {
48 strict: true
49 }
50 },
51
52 ssr: {
53 // Don't externalize these in SSR
54 noExternal: []
55 }
56});