-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
114 lines (104 loc) · 2.79 KB
/
vite.config.ts
File metadata and controls
114 lines (104 loc) · 2.79 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
/**
* Vite Configuration - Optimized for AnyCowork
*/
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
export default defineConfig({
plugins: [
react({
// Enable Fast Refresh
fastRefresh: true,
// Remove dev-only code in production
babel: {
plugins: [
// process.env.NODE_ENV === "production" && [
// "transform-remove-console",
// { exclude: ["error", "warn"] },
// ],
].filter(Boolean),
},
}),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./"),
},
},
server: {
port: 5173,
strictPort: true,
host: true, // Listen on all addresses
// Proxy not strictly needed if we access via backend, but helpful for direct dev
proxy: {
"/api": {
target: process.env.VITE_API_URL || "http://localhost:8080",
changeOrigin: true,
},
},
hmr: {
clientPort: 5173,
},
watch: {
// Exclude directories that shouldn't be watched
ignored: [
"**/node_modules/**",
"**/src-tauri/target/**",
"**/dist/**",
"**/.git/**",
],
},
},
build: {
outDir: "dist",
emptyOutDir: true,
sourcemap: false,
minify: "esbuild", // Faster than terser
target: "esnext", // Modern browsers only
// Optimize chunk sizes
chunkSizeWarningLimit: 1000,
rollupOptions: {
output: {
// Optimize manual chunks for better caching
// Optimize manual chunks for better caching
// manualChunks: (id) => {
// // Vendor chunk for core libraries
// if (id.includes("node_modules")) {
// if (id.includes("react") || id.includes("react-dom")) {
// return "vendor-react";
// }
// if (id.includes("react-router")) {
// return "vendor-router";
// }
// if (id.includes("@tanstack/react-query")) {
// return "vendor-query";
// }
// if (id.includes("lucide-react")) {
// return "vendor-icons";
// }
// if (id.includes("@radix-ui")) {
// return "vendor-ui";
// }
// // All other node_modules in one chunk
// return "vendor";
// }
// },
// Optimize filenames for better caching
chunkFileNames: "assets/[name]-[hash].js",
entryFileNames: "assets/[name]-[hash].js",
assetFileNames: "assets/[name]-[hash][extname]",
},
},
// Enable CSS code splitting
cssCodeSplit: true,
},
// Optimize dependencies
optimizeDeps: {
include: [
"react",
"react-dom",
"react-router-dom",
"@tanstack/react-query",
],
},
});