Very minor optimization options

This commit is contained in:
Antoine Phan
2025-10-13 22:06:37 -04:00
parent a1c40ccba4
commit 9052b02e56
3 changed files with 51 additions and 5 deletions

View File

@@ -1,13 +1,19 @@
<script> <script>
import '../app.css'; import '../app.css';
import { dev } from '$app/environment'; import { dev } from '$app/environment';
import { inject } from '@vercel/analytics'; import { onMount } from 'svelte';
import Navbar from 'components/layout/NavBar.svelte'; import Navbar from 'components/layout/NavBar.svelte';
import Footer from 'components/layout/Footer.svelte'; import Footer from 'components/layout/Footer.svelte';
inject({ mode: dev ? 'development' : 'production' });
let { children } = $props(); let { children } = $props();
// Lazy load analytics only in production for faster dev startup
onMount(async () => {
if (!dev) {
const { inject } = await import('@vercel/analytics');
inject({ mode: 'production' });
}
});
</script> </script>
<Navbar /> <Navbar />

View File

@@ -12,7 +12,10 @@ const config = {
} }
}, },
preprocess: [], preprocess: [],
extensions: ['.svelte']
compilerOptions: {
runes: true
}
}; };
export default config; export default config;

View File

@@ -4,7 +4,44 @@ import { defineConfig } from 'vite';
export default defineConfig({ export default defineConfig({
plugins: [sveltekit(), tailwindcss()], plugins: [sveltekit(), tailwindcss()],
// Optimize dependency pre-bundling
optimizeDeps: { optimizeDeps: {
include: ['@portabletext/svelte', '@lucide/svelte'] include: [
'@portabletext/svelte',
'@lucide/svelte',
'@skeletonlabs/skeleton-svelte',
'@sanity/client'
],
// Force pre-bundle these dependencies
force: false
},
// Build optimizations
build: {
target: 'esnext',
minify: 'esbuild',
cssMinify: true,
},
// Server optimizations for dev
server: {
fs: {
// Allow serving files from project root
strict: false
},
warmup: {
// Pre-transform commonly used files
clientFiles: [
'./src/routes/+layout.svelte',
'./src/routes/+page.svelte',
'./src/components/layout/*.svelte'
]
}
},
// Resolve optimizations
resolve: {
dedupe: ['svelte']
} }
}); });