-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.js
68 lines (64 loc) · 1.62 KB
/
vite.config.js
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
// vite.config.js
import react from "@vitejs/plugin-react";
import { visualizer } from "rollup-plugin-visualizer";
import { defineConfig, loadEnv, splitVendorChunkPlugin } from "vite";
import eslint from "vite-plugin-eslint";
import { ViteMinifyPlugin } from "vite-plugin-minify";
import { VitePluginRadar } from "vite-plugin-radar";
import svgr from "vite-plugin-svgr";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
const external = [
"mathematica.js",
"isbl.js",
"1c.js",
"maxima.js",
"sqf.js",
"gml.js",
];
return {
plugins: [
react(),
svgr(),
VitePluginRadar({
analytics: {
id: `${env.VITE_GA_ID ?? ""}`,
config: {
cookie_flags: "SameSite=None;Secure",
},
},
}),
eslint(),
ViteMinifyPlugin({}),
visualizer(),
],
build: {
rollupOptions: {
output: {
manualChunks(id) {
for (const e of external) {
if (id.includes(e)) {
return "extra-lang";
}
}
if (id.includes("react-github-readme-button")) {
return "github-button";
}
if (id.includes("highlight.js")) {
return "highlight.js";
}
if (id.includes("@apollo")) {
return "@apollo";
}
if (id.includes("graphql")) {
return "graphql";
}
if (id.includes("node_modules")) {
return "vendor";
}
},
},
},
},
};
});