Files
encoach_frontend_new_v2/vite.config.ts
2026-04-26 03:12:52 +04:00

70 lines
2.4 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import path from "path";
import { componentTagger } from "lovable-tagger";
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
server: {
host: "::",
port: 8080,
// Browser blocks :8080 → :8069 (CORS). Proxy /api to Odoo so fetch stays same-origin.
proxy: {
"/api": {
target: "http://127.0.0.1:8069",
changeOrigin: true,
},
},
hmr: {
overlay: false,
},
},
plugins: [react(), mode === "development" && componentTagger()].filter(Boolean),
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
build: {
// Raise warning threshold slightly — route chunks and the charts vendor
// bundle legitimately trend 300500KB each and we already code-split.
chunkSizeWarningLimit: 900,
rollupOptions: {
output: {
manualChunks: {
// Pin the React core to its own chunk — it's in the critical path on
// every route and never changes between deploys, so users cache it.
"vendor-react": ["react", "react-dom", "react-router-dom"],
// React Query + auth context sit behind every authenticated page.
"vendor-query": ["@tanstack/react-query"],
// Recharts is large and only used on dashboard/report pages; keeping
// it separate lets the login/landing chunks stay small.
"vendor-charts": ["recharts"],
// Radix/shadcn primitives are shared across most pages.
"vendor-radix": [
"@radix-ui/react-dialog",
"@radix-ui/react-dropdown-menu",
"@radix-ui/react-popover",
"@radix-ui/react-select",
"@radix-ui/react-tabs",
"@radix-ui/react-toast",
"@radix-ui/react-tooltip",
"@radix-ui/react-accordion",
"@radix-ui/react-checkbox",
"@radix-ui/react-label",
"@radix-ui/react-progress",
"@radix-ui/react-radio-group",
"@radix-ui/react-scroll-area",
"@radix-ui/react-separator",
"@radix-ui/react-slider",
"@radix-ui/react-switch",
"@radix-ui/react-avatar",
],
"vendor-forms": ["react-hook-form", "@hookform/resolvers", "zod"],
"vendor-icons": ["lucide-react"],
},
},
},
},
}));