Repository navigation
Expand file tree
/
Copy pathvite.config.js
More file actions
71 lines (69 loc) · 1.86 KB
/
Copy pathvite.config.js
File metadata and controls
71 lines (69 loc) · 1.86 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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import tailwindcss from "@tailwindcss/vite";
import path from "path";
const preloadLatinFont = () => ({
name: "preload-latin-font",
transformIndexHtml: {
order: "post",
handler(html, ctx) {
const font = Object.keys(ctx.bundle ?? {}).find((file) =>
/inter-latin-wght-normal-[\w-]+\.woff2$/.test(file)
);
if (!font) return html;
return [
{
tag: "link",
attrs: { rel: "preload", href: `/${font}`, as: "font", type: "font/woff2", crossorigin: "" },
injectTo: "head",
},
];
},
},
});
export default defineConfig({
server: {
host: "::",
port: 8080,
headers: {
'Content-Security-Policy': "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.gpteng.co; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self' https:;"
}
},
plugins: [react(), tailwindcss(), preloadLatinFont()],
resolve: {
alias: {
"@": path.resolve(process.cwd(), "./src"),
"lib": path.resolve(process.cwd(), "./lib"),
},
},
build: {
rolldownOptions: {
output: {
advancedChunks: {
groups: [
{
name: 'react-vendor',
test: /[\\/]node_modules[\\/](react|react-dom|react-router|react-router-dom)[\\/]/,
},
{
name: 'ui-vendor',
test: /[\\/]node_modules[\\/]@radix-ui[\\/]/,
},
{
name: 'math-vendor',
test: /[\\/]node_modules[\\/]mathjs[\\/]/,
},
],
},
}
},
sourcemap: true,
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true
}
}
}
});