-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
54 lines (50 loc) · 1.62 KB
/
Copy pathvite.config.ts
File metadata and controls
54 lines (50 loc) · 1.62 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
import { resolve } from "node:path";
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
const fallbackByMode: Record<string, { base: string }> = {
localhost: { base: "/" },
local: { base: "/" },
cloudflare: { base: "/" },
production: { base: "/" },
github: { base: "/ads/" },
};
function normalizeBasePath(value?: string) {
const raw = (value || "/").trim();
if (!raw || raw === ".") return "/";
const withSlash = raw.startsWith("/") ? raw : `/${raw}`;
return withSlash.endsWith("/") ? withSlash : `${withSlash}/`;
}
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const fallback = fallbackByMode[mode] || fallbackByMode.production;
const base = normalizeBasePath(process.env.VITE_BASE_PATH || env.VITE_BASE_PATH || fallback.base);
return {
base,
plugins: [react(), tailwindcss()],
build: {
rollupOptions: {
input: {
main: resolve(__dirname, "index.html"),
app: resolve(__dirname, "app/index.html"),
},
output: {
manualChunks(id) {
if (id.includes("node_modules/framer-motion")) return "motion";
if (id.includes("node_modules/lucide-react")) return "icons";
if (id.includes("node_modules/react") || id.includes("node_modules/react-dom")) return "react";
if (id.includes("node_modules/zustand")) return "state";
},
},
},
},
server: {
host: "127.0.0.1",
port: 5177,
},
preview: {
host: "127.0.0.1",
port: 4177,
},
};
});