-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathvite.config.ts
55 lines (49 loc) · 1.33 KB
/
vite.config.ts
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
/// <reference types="vitest/config" />
import { spawnSync } from "child_process";
import react from "@vitejs/plugin-react-swc";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
function consolidateSnippets(projectRoot: string) {
const cmd = spawnSync("tsx", ["utils/consolidateSnippets.ts"], {
cwd: projectRoot,
});
if (cmd.status === 0) return;
console.log(`Consolidating snippets failed:\n${cmd.output.toString()}`);
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
tsconfigPaths(),
{
name: "Consolidate Snippet",
configResolved({ root }) {
consolidateSnippets(root);
},
handleHotUpdate({ file, server }) {
const relativePath = file.slice(server.config.root.length);
if (!relativePath.startsWith("/snippets/")) return;
consolidateSnippets(server.config.root);
},
},
],
test: {
setupFiles: ["/tests/setup.ts"],
coverage: {
provider: "v8",
},
},
build: {
rollupOptions: {
output: {
manualChunks: {
prismjs: ["prismjs"],
react: ["react"],
"react-dom": ["react-dom"],
"react-router-dom": ["react-router-dom"],
"react-syntax-highlighter": ["react-syntax-highlighter"],
},
},
},
},
});