-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.static.config.ts
More file actions
79 lines (74 loc) · 1.93 KB
/
Copy pathvite.static.config.ts
File metadata and controls
79 lines (74 loc) · 1.93 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
import { tanstackRouter } from "@tanstack/router-plugin/vite";
import react from "@vitejs/plugin-react";
import { defineConfig, loadEnv } from "vite";
import { viteStaticCopy } from "vite-plugin-static-copy";
import fs from "node:fs";
import path from "node:path";
function existsSync(relativePath: string): boolean {
return fs.existsSync(path.resolve(process.cwd(), relativePath));
}
const staticCopyTargets: { src: string; dest: string }[] = [];
if (existsSync("node_modules/@openbb/ui/dist/assets")) {
staticCopyTargets.push({
src: "node_modules/@openbb/ui/dist/assets/*",
dest: "",
});
}
if (existsSync("../docs")) {
staticCopyTargets.push({
src: "../docs/*",
dest: "docs",
});
}
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "VITE");
return {
base: env.VITE_APP_BASE || "/",
plugins: [
tanstackRouter({
target: "react",
autoCodeSplitting: false,
generatedRouteTree: "./src/routeTree.gen.ts",
}),
react(),
...(staticCopyTargets.length > 0
? [
viteStaticCopy({
targets: staticCopyTargets,
}),
]
: []),
],
resolve: {
alias: {
"@": "/src",
"@shared": "/../shared",
},
},
build: {
outDir: "dist-static",
sourcemap: false,
chunkSizeWarningLimit: 1000,
rollupOptions: {
output: {
manualChunks: (id: string) => {
if (id.includes("node_modules")) {
if (
id.includes("react") &&
!id.includes("react-router") &&
!id.includes("react-query")
) {
return "vendor";
}
if (id.includes("react-router")) return "router";
if (id.includes("recharts") || id.includes("chart"))
return "charts";
if (id.includes("i18n")) return "i18n";
return "vendor";
}
},
},
},
},
};
});