Very minor optimization options
This commit is contained in:
@@ -1,13 +1,19 @@
|
||||
<script>
|
||||
import '../app.css';
|
||||
import { dev } from '$app/environment';
|
||||
import { inject } from '@vercel/analytics';
|
||||
import { onMount } from 'svelte';
|
||||
import Navbar from 'components/layout/NavBar.svelte';
|
||||
import Footer from 'components/layout/Footer.svelte';
|
||||
|
||||
inject({ mode: dev ? 'development' : 'production' });
|
||||
|
||||
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>
|
||||
|
||||
<Navbar />
|
||||
|
||||
@@ -12,7 +12,10 @@ const config = {
|
||||
}
|
||||
},
|
||||
preprocess: [],
|
||||
extensions: ['.svelte']
|
||||
|
||||
compilerOptions: {
|
||||
runes: true
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
||||
@@ -4,7 +4,44 @@ import { defineConfig } from 'vite';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [sveltekit(), tailwindcss()],
|
||||
|
||||
// Optimize dependency pre-bundling
|
||||
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']
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user