Repository navigation
Expand file tree
/
Copy pathvite.config.js
More file actions
133 lines (124 loc) · 4.58 KB
/
Copy pathvite.config.js
File metadata and controls
133 lines (124 loc) · 4.58 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
/// <reference types="vitest" />
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from '@tailwindcss/vite'
// recharts and the packages only it brings in (see `pnpm why`).
const CHART_DEPS = /[\\/]node_modules[\\/](recharts|d3-[^\\/]+|victory-vendor|react-redux|@reduxjs|redux|redux-thunk|reselect|immer|decimal\.js-light|es-toolkit|eventemitter3|use-sync-external-store|tiny-invariant)[\\/]/
export default defineConfig({
plugins: [react(),
tailwindcss(),
],
build: {
rollupOptions: {
output: {
// Use a function for dynamic chunk splitting
manualChunks(id) {
// Vendor libraries - Split by categories
if (id.includes('node_modules')) {
// Charts: left unassigned so they stay in the lazy analytics chunk.
// Naming a group here would also pull its dependencies (react-dom)
// into it, and every page would then preload the charts.
if (CHART_DEPS.test(id)) {
return undefined;
}
// React ecosystem
if (id.includes('react') || id.includes('react-dom')) {
return 'react-vendor';
}
// Router
if (id.includes('react-router')) {
return 'router-vendor';
}
// Supabase and database
if (id.includes('@supabase') || id.includes('@prisma')) {
return 'supabase-vendor';
}
// UI libraries
if (id.includes('lucide-react') || id.includes('clsx')) {
return 'ui-vendor';
}
// Analytics
if (id.includes('@vercel/analytics')) {
return 'analytics-vendor';
}
// Other large vendor libraries
return 'vendor';
}
// Feature-based splitting for our code
// Analytics screen: unassigned so the lazy import gets its own chunk
if (id.includes('/admin/analytics/') || id.endsWith('/admin/Analytics.jsx')) {
return undefined;
}
// Admin features
if (id.includes('/admin/') || id.includes('AdminApp') || id.includes('SecureAdminApp')) {
return 'admin';
}
// Auth features
if (id.includes('/auth/') || id.includes('Auth/') || id.includes('LoginPage') || id.includes('RegisterPage')) {
return 'auth';
}
// Landing and marketing pages
if (id.includes('/landing/') || id.includes('Landing/') || id.includes('LandingPage')) {
return 'landing';
}
// Table and tenant specific features
if (id.includes('TableApp') || id.includes('MenuLayout') || id.includes('/layout/')) {
return 'tenant';
}
// Cart and ecommerce features
if (id.includes('/cart/') || id.includes('Cart') || id.includes('CartContext')) {
return 'cart';
}
// Context providers and hooks (shared)
if (id.includes('/context/') || id.includes('/hooks/')) {
return 'shared';
}
},
// Optional: Control chunk size and naming
chunkFileNames: () => `assets/[name]-[hash].js`
}
},
// Increase chunk size warning limit slightly since we're splitting appropriately
chunkSizeWarningLimit: 600
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: './src/test/setup.js',
css: true,
// 2.4/2.5: CartContext y TenantContext re-habilitados tras el flip a rutas
// server (placeOrder → POST /api/orders, sesiones → POST /api/table-sessions)
exclude: ['**/node_modules/**'],
},
server: {
host: "0.0.0.0", // Permite conexiones externas
port: 5173,
// Proxy para API routes (Vercel serverless functions)
// Requiere: node dev-server.js (corre en :3001)
proxy: {
'/api': {
target: 'http://localhost:3001',
changeOrigin: true,
},
},
// Permitir hosts personalizados para subdominios
allowedHosts: [
"tappmesa.local",
"cafe-central.tappmesa.local",
"admin.tappmesa.local",
".tappmesa.local", // Wildcard para cualquier subdominio
".localhost", // Wildcard para subdominios .localhost
"cafe-central.localhost",
"admin.localhost",
],
// Configuración para subdominios locales
hmr: {
host: "localhost",
},
},
preview: {
host: "0.0.0.0",
port: 4173,
allowedHosts: ["tappmesa.local", ".tappmesa.local", ".localhost"],
},
});