forked from TanStack/tanstack.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
104 lines (101 loc) · 2.78 KB
/
vite.config.ts
File metadata and controls
104 lines (101 loc) · 2.78 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import { sentryVitePlugin } from '@sentry/vite-plugin'
import { defineConfig } from 'vite'
import contentCollections from '@content-collections/vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import tailwindcss from '@tailwindcss/vite'
import { analyzer } from 'vite-bundle-analyzer'
import viteReact from '@vitejs/plugin-react'
import netlify from '@netlify/vite-plugin-tanstack-start'
export default defineConfig({
server: {
port: 3000,
},
ssr: {
external: ['postgres'],
noExternal: ['drizzle-orm'],
},
optimizeDeps: {
exclude: ['postgres'],
},
build: {
sourcemap: process.env.NODE_ENV === 'production',
rollupOptions: {
external: (id) => {
// Externalize postgres from client bundle
return id.includes('postgres')
},
output: {
manualChunks: (id) => {
// Vendor chunk splitting for better caching
if (id.includes('node_modules')) {
// Search-related deps (only loaded when search modal opens)
if (
id.includes('algoliasearch') ||
id.includes('instantsearch') ||
id.includes('react-instantsearch')
) {
return 'search'
}
// Charting deps (only loaded on stats/admin pages)
if (
id.includes('@observablehq/plot') ||
(id.includes('d3') && !id.includes('d3-'))
) {
return 'd3-charts'
}
// Visualization deps
if (id.includes('@visx/')) {
return 'visx'
}
// Lucide icons (tree-shaken but still significant)
if (id.includes('lucide-react')) {
return 'icons'
}
}
},
},
},
},
plugins: [
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
tanstackStart({
router: {
codeSplittingOptions: {
defaultBehavior: [
[
'component',
'pendingComponent',
'errorComponent',
'notFoundComponent',
'loader',
],
],
},
},
}),
// Only enable Netlify plugin during build or when NETLIFY env is set
...(process.env.NETLIFY || process.env.NODE_ENV === 'production'
? [netlify()]
: []),
viteReact(),
sentryVitePlugin({
authToken: process.env.SENTRY_AUTH_TOKEN,
org: 'tanstack',
project: 'tanstack-com',
}),
contentCollections(),
tailwindcss(),
...(process.env.ANALYZE
? [
analyzer({
analyzerMode: 'json',
fileName: 'bundle-analysis',
defaultSizes: 'stat',
}),
]
: []),
],
})