Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
53 lines (52 loc) · 1.48 KB
/
Copy pathvite.config.ts
File metadata and controls
53 lines (52 loc) · 1.48 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
import react from "@vitejs/plugin-react";
import { createHash } from "node:crypto";
import path from "node:path";
import { defineConfig } from "vite";
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (!id.includes("node_modules")) {
return undefined;
}
if (id.includes("/node_modules/telegram/")) {
return "telegram";
}
if (
id.includes("/node_modules/react/") ||
id.includes("/node_modules/react-dom/") ||
id.includes("/node_modules/jotai/") ||
id.includes("/node_modules/clsx/") ||
id.includes("/node_modules/ramda/") ||
id.includes("/node_modules/embla-carousel-react/")
) {
return "vendor";
}
return undefined;
},
},
},
},
css: {
modules: {
generateScopedName: (localName, filename) => {
const cleanName = path.basename(filename).split("?")[0];
const base = cleanName
.replace(/\.module\.css$/i, "")
.replace(/\.css$/i, "")
.replace(/\.module$/i, "");
const hash = createHash("sha256")
.update(localName)
.update(base)
.update(filename)
.digest("base64")
.replace(/[+/=]/g, "")
.slice(0, 6);
return `${base}__${localName}__${hash}`;
},
},
},
});