Skip to content

Commit 347f4bb

Browse files
committed
feat: enhance esbuild configuration for production and improve chunking strategy
1 parent f8312f8 commit 347f4bb

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

davian-space-site/vite.config.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ export default defineConfig({
3939
deferCSSPlugin()
4040
],
4141
base: "/",
42+
// esbuild configuration for production
43+
esbuild: {
44+
drop: ['console', 'debugger'], // Remove console.log and debugger in production
45+
legalComments: 'none'
46+
},
4247
build: {
4348
// Enable content-based hashing for cache busting
4449
rollupOptions: {
@@ -57,16 +62,18 @@ export default defineConfig({
5762
manualChunks: (id) => {
5863
// Vendor chunks
5964
if (id.includes('node_modules')) {
60-
// React core - most critical, keep separate
61-
if (id.includes('react') || id.includes('react-dom')) {
65+
// React core and react-dom together (prevents circular dependency)
66+
if (id.includes('react') || id.includes('react-dom') || id.includes('scheduler')) {
6267
return 'react-vendor';
6368
}
6469
// Lucide icons - split into separate chunk
6570
if (id.includes('lucide-react')) {
6671
return 'icons';
6772
}
6873
// Other vendor code
69-
return 'vendor';
74+
if (id.includes('node_modules')) {
75+
return 'vendor';
76+
}
7077
}
7178
}
7279
}
@@ -79,15 +86,9 @@ export default defineConfig({
7986
assetsInlineLimit: 15360, // Inline assets under 15KB including CSS
8087
// CSS code splitting
8188
cssCodeSplit: false, // Bundle all CSS into one file for better caching
82-
// Minification options for better compression
83-
minify: 'terser',
84-
terserOptions: {
85-
compress: {
86-
drop_console: true, // Remove console.log in production
87-
drop_debugger: true,
88-
pure_funcs: ['console.log', 'console.info', 'console.debug']
89-
}
90-
}
89+
// Minification with esbuild (faster and built-in)
90+
minify: 'esbuild',
91+
target: 'es2015'
9192
},
9293
// Optimize dependencies
9394
optimizeDeps: {

0 commit comments

Comments
 (0)