Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
71 lines (70 loc) · 2.1 KB
/
Copy pathvite.config.ts
File metadata and controls
71 lines (70 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import tailwindcss from "@tailwindcss/vite";
export default defineConfig({
plugins: [
react(),
tailwindcss(),
],
build: {
rollupOptions: {
output: {
manualChunks: (id) => {
// More granular code splitting
if (id.includes('node_modules')) {
if (id.includes('react') || id.includes('react-dom')) {
return 'react-vendor';
}
if (id.includes('gsap')) {
return 'animation-vendor';
}
if (id.includes('react-icons')) {
return 'ui-vendor';
}
// Other node_modules go into vendor chunk
return 'vendor';
}
},
// Optimize asset file names for better caching
assetFileNames: (assetInfo) => {
const info = assetInfo.name?.split('.');
const ext = info?.[info.length - 1];
if (/png|jpe?g|svg|gif|tiff|bmp|ico/i.test(ext || '')) {
return `assets/images/[name]-[hash][extname]`;
}
if (/woff2?|ttf|eot/i.test(ext || '')) {
return `assets/fonts/[name]-[hash][extname]`;
}
return `assets/[name]-[hash][extname]`;
},
chunkFileNames: 'assets/js/[name]-[hash].js',
entryFileNames: 'assets/js/[name]-[hash].js',
},
},
// Disable sourcemaps in production for smaller bundle size
sourcemap: false,
// Optimize chunk size
chunkSizeWarningLimit: 1000,
// Minify with esbuild for faster builds (default)
minify: 'esbuild',
// Target modern browsers for smaller bundle size
target: 'esnext',
// Enable CSS code splitting
cssCodeSplit: true,
},
// Optimize dependencies
optimizeDeps: {
include: ['react', 'react-dom', 'gsap', '@gsap/react'],
exclude: ['@vite/client', '@vite/env'],
},
// Performance hints
server: {
warmup: {
clientFiles: [
'./src/App.tsx',
'./src/components/Home/Hero/Hero.tsx',
'./src/layout/Header/Header.tsx',
],
},
},
});