-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
259 lines (205 loc) · 9.29 KB
/
vite.config.ts
File metadata and controls
259 lines (205 loc) · 9.29 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
import {defineConfig, loadEnv} from 'vite'
import react from '@vitejs/plugin-react-swc'
import tailwindcss from '@tailwindcss/vite'
import path from 'node:path'
import viteBasicSslPlugin from "@vitejs/plugin-basic-ssl";
// https://vite.dev/config/
export default ({ mode }: { mode: string }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }
return defineConfig({
plugins: [
viteBasicSslPlugin({
name: 'localhost',
certDir: '.certs'
}),
react(),
tailwindcss()
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
}
},
build: {
rolldownOptions: {
output: {
advancedChunks: {
groups: [
// 1) Core de Recharts (ejes, utils, componentes comunes)
{
name: 'rechart-core',
test: /node_modules[\\/]recharts[\\/](lib|es|src)?[\\/](component|util|shape|container|context|cartesian[\\/]Cartesian|polar[\\/]Polar)/,
priority: 50, // alta prioridad para capturar dependencias comunes primero
},
// 2) Chunks por tipo de gráfico de Recharts (name dinámico)
{
// Un solo grupo que devuelve N nombres => N chunks
name: (id: string) => {
if (!/node_modules[\\/]recharts/.test(id)) return null
// line
if (/(LineChart|[\\/]cartesian[\\/]Line(\.|[\\/]))/.test(id)) return 'rechart-line'
// bar
if (/(BarChart|[\\/]cartesian[\\/]Bar(\.|[\\/]))/.test(id)) return 'rechart-bars'
// area
if (/(AreaChart|[\\/]cartesian[\\/]Area(\.|[\\/]))/.test(id)) return 'rechart-area'
// pie / donut
if (/(PieChart|[\\/]polar[\\/]Pie(\.|[\\/]))/.test(id)) return 'rechart-pie'
// radar
if (/(RadarChart|[\\/]polar[\\/]Radar(\.|[\\/]))/.test(id)) return 'rechart-radar'
// radial bar
if (/(RadialBarChart|[\\/]polar[\\/]RadialBar(\.|[\\/]))/.test(id)) return 'rechart-radialbar'
// scatter
if (/(ScatterChart|[\\/]cartesian[\\/]Scatter(\.|[\\/]))/.test(id)) return 'rechart-scatter'
// treemap
if (/([\\/]Treemap(\.|[\\/]))/.test(id)) return 'rechart-treemap'
// fallback: mete cualquier otro módulo de recharts aquí
return 'rechart-misc'
},
// restringe a recharts para que no toque otros paquetes
test: /node_modules[\\/]recharts[\\/]/,
priority: 40,
},
// 3) Firebase Core (app, utils, dependencias comunes)
{
name: 'firebase-core',
test: /node_modules[\\/]firebase[\\/](app|util|logger|component|webchannel-wrapper)/,
priority: 50, // alta prioridad para capturar dependencias comunes primero
},
// 4) Chunks por servicio de Firebase (name dinámico)
{
name: (id: string) => {
if (!/node_modules[\\/]firebase[\\/]/.test(id)) return null
// auth
if (/([\\/]auth[\\/])/.test(id)) return 'firebase-auth'
// firestore
if (/([\\/]firestore[\\/])/.test(id)) return 'firebase-firestore'
// storage
if (/([\\/]storage[\\/])/.test(id)) return 'firebase-storage'
// database (realtime)
if (/([\\/]database[\\/])/.test(id)) return 'firebase-database'
// functions
if (/([\\/]functions[\\/])/.test(id)) return 'firebase-functions'
// messaging
if (/([\\/]messaging[\\/])/.test(id)) return 'firebase-messaging'
// analytics
if (/([\\/]analytics[\\/])/.test(id)) return 'firebase-analytics'
// performance
if (/([\\/]performance[\\/])/.test(id)) return 'firebase-performance'
// remote-config
if (/([\\/]remote-config[\\/])/.test(id)) return 'firebase-remote-config'
// installations
if (/([\\/]installations[\\/])/.test(id)) return 'firebase-installations'
// fallback: mete cualquier otro módulo de firebase aquí
return 'firebase-misc'
},
// restringe a firebase para que no toque otros paquetes
test: /node_modules[\\/]firebase[\\/]/,
priority: 40,
},
// 5) Radix UI Core (primitives comunes, utils, shared)
{
name: 'radix-core',
test: /node_modules[\\/]@radix-ui[\\/](react-primitive|react-compose-refs|react-context|react-use-|react-id|react-portal|react-presence|react-dismissable-layer|react-focus-|react-slot)/,
priority: 50, // alta prioridad para capturar dependencias comunes primero
},
// 6) Chunks por componente de Radix UI (name dinámico)
{
name: (id: string) => {
if (!/node_modules[\\/]@radix-ui[\\/]/.test(id)) return null
// dialog (usado por sheet)
if (/(react-dialog)/.test(id)) return 'radix-dialog'
// dropdown-menu
if (/(react-dropdown-menu)/.test(id)) return 'radix-dropdown-menu'
// select
if (/(react-select)/.test(id)) return 'radix-select'
// tooltip
if (/(react-tooltip)/.test(id)) return 'radix-tooltip'
// popover
if (/(react-popover)/.test(id)) return 'radix-popover'
// separator
if (/(react-separator)/.test(id)) return 'radix-separator'
// accordion
if (/(react-accordion)/.test(id)) return 'radix-accordion'
// alert-dialog
if (/(react-alert-dialog)/.test(id)) return 'radix-alert-dialog'
// checkbox
if (/(react-checkbox)/.test(id)) return 'radix-checkbox'
// collapsible
if (/(react-collapsible)/.test(id)) return 'radix-collapsible'
// hover-card
if (/(react-hover-card)/.test(id)) return 'radix-hover-card'
// label
if (/(react-label)/.test(id)) return 'radix-label'
// menubar
if (/(react-menubar)/.test(id)) return 'radix-menubar'
// navigation-menu
if (/(react-navigation-menu)/.test(id)) return 'radix-navigation-menu'
// progress
if (/(react-progress)/.test(id)) return 'radix-progress'
// radio-group
if (/(react-radio-group)/.test(id)) return 'radix-radio-group'
// scroll-area
if (/(react-scroll-area)/.test(id)) return 'radix-scroll-area'
// slider
if (/(react-slider)/.test(id)) return 'radix-slider'
// switch
if (/(react-switch)/.test(id)) return 'radix-switch'
// tabs
if (/(react-tabs)/.test(id)) return 'radix-tabs'
// toggle
if (/(react-toggle)/.test(id)) return 'radix-toggle'
// toggle-group
if (/(react-toggle-group)/.test(id)) return 'radix-toggle-group'
// toolbar
if (/(react-toolbar)/.test(id)) return 'radix-toolbar'
// fallback: mete cualquier otro módulo de radix-ui aquí
return 'radix-misc'
},
// restringe a radix-ui para que no toque otros paquetes
test: /node_modules[\\/]@radix-ui[\\/]/,
priority: 40,
},
// 7) Otros vendors grandes (React y chart.js si también usas)
{
test: /node_modules[\\/]react(-dom)?[\\/]/,
name: 'react-vendors',
priority: 30,
},
{
test: /node_modules[\\/]chart\.js[\\/]/,
name: 'chartjs-vendor',
priority: 30,
},
// 8) resto de node_modules
{
test: /node_modules[\\/]/,
name: 'libs',
priority: 10,
},
// 9) tu código
{ test: /src[\\/]components[\\/]/, name: 'components' },
{ test: /src[\\/]utils[\\/]/, name: 'utils' },
],
},
},
},
},
server: {
allowedHosts: true,
host: true,
https: {
cert: './.certs/_cert.pem',
},
// Proxy solo se usa en modo desarrollo (npm run dev)
// En producción, se usa directamente VITE_API_BASE_URL del .env
proxy: {
'/api': {
target: 'https://api-website.exdev.cl',
changeOrigin: true,
secure: true,
rewrite: (path) => path.replace(/^\/api/, ''),
}
},
}
})
}