-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
73 lines (66 loc) · 1.91 KB
/
Copy pathvite.config.ts
File metadata and controls
73 lines (66 loc) · 1.91 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
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
// 🌍 Universal Vite config (works on local + Vercel)
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
return {
plugins: [
react(),
// You can add viteCompression or viteImagemin here later if needed
],
// 🧠 Smart dependency optimization
optimizeDeps: {
exclude: ["lucide-react"],
},
// 🧩 Folder aliases for cleaner imports
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"@components": path.resolve(__dirname, "./src/components"),
"@assets": path.resolve(__dirname, "./src/assets"),
"@hooks": path.resolve(__dirname, "./src/hooks"),
"@utils": path.resolve(__dirname, "./src/utils"),
},
},
// ⚙️ Dev server config
server: {
port: 5173,
open: true,
cors: true,
proxy: {
"/api": {
target: "http://localhost:3001",
changeOrigin: true,
secure: false,
},
},
},
// 🚀 Build optimizations
build: {
target: "esnext",
sourcemap: false,
cssCodeSplit: true,
minify: "terser",
chunkSizeWarningLimit: 2000,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes("node_modules")) {
if (id.includes("react") || id.includes("react-dom")) return "react";
if (id.includes("framer-motion")) return "motion";
if (id.includes("gsap")) return "gsap";
if (id.includes("zustand")) return "store";
if (id.includes("swiper")) return "swiper";
return "vendor";
}
},
},
},
},
// 🌍 Global environment variable exposure
define: {
__APP_ENV__: JSON.stringify(env.APP_ENV),
},
};
});