-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
93 lines (89 loc) · 2.61 KB
/
vite.config.ts
File metadata and controls
93 lines (89 loc) · 2.61 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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import chromeManifest from "./public/manifest.json";
import { crx, ManifestV3Export } from "@crxjs/vite-plugin";
const vendorChunkGroups: Record<string, string[]> = {
"react-vendor": [
"/node_modules/react/",
"/node_modules/react-dom/",
"/node_modules/react-redux/",
"/node_modules/@reduxjs/toolkit/",
"/node_modules/use-sync-external-store/",
],
"mui-core": [
"/node_modules/@mui/material/",
"/node_modules/@emotion/react/",
"/node_modules/@emotion/styled/",
"/node_modules/@emotion/cache/",
"/node_modules/@emotion/serialize/",
"/node_modules/@emotion/sheet/",
"/node_modules/@emotion/unitless/",
"/node_modules/@emotion/utils/",
"/node_modules/@babel/runtime/",
],
"mui-icons": ["/node_modules/@mui/icons-material/"],
"mui-pickers": [
"/node_modules/@mui/x-date-pickers/",
"/node_modules/date-fns/",
"/node_modules/date-fns-tz/",
],
"markdown-vendor": [
"/node_modules/react-markdown/",
"/node_modules/remark-parse/",
"/node_modules/remark-rehype/",
"/node_modules/unified/",
"/node_modules/mdast-util-",
"/node_modules/micromark",
"/node_modules/hast-util-",
"/node_modules/vfile/",
],
"highlight-vendor": ["/node_modules/highlight.js/"],
"file-processing-vendor": [
"/node_modules/file-type/",
"/node_modules/@tokenizer/",
"/node_modules/token-types/",
"/node_modules/peek-readable/",
"/node_modules/strtok3/",
"/node_modules/uint8array-extras/",
"/node_modules/ieee754/",
],
"export-utils-vendor": [
"/node_modules/flat/",
"/node_modules/nanoid/",
"/node_modules/streamsaver/",
],
"windowing-vendor": ["/node_modules/react-window/"],
"utility-vendor": [
"/node_modules/copy-to-clipboard/",
"/node_modules/classnames/",
"/node_modules/debounce/",
"/node_modules/@transcend-io/conflux/",
"/node_modules/bytes/",
],
};
const resolveVendorChunk = (id: string) => {
for (const [chunkName, matchers] of Object.entries(vendorChunkGroups)) {
if (matchers.some((matcher) => id.includes(matcher))) {
return chunkName;
}
}
return id.includes("/node_modules/") ? "vendor-misc" : undefined;
};
// https://vitejs.dev/config/
export default defineConfig({
build: {
rollupOptions: {
input: { main: "index.html", button_injection: "button_injection.html" },
output: {
entryFileNames: "[name].js",
manualChunks: resolveVendorChunk,
},
},
},
plugins: [
react(),
crx({
manifest: chromeManifest as ManifestV3Export,
}),
],
});