-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathvite.config.ts
More file actions
72 lines (69 loc) · 2.02 KB
/
vite.config.ts
File metadata and controls
72 lines (69 loc) · 2.02 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
/// <reference types="vitest" />
import { defineConfig } from "vite";
import analog from "@analogjs/platform";
import * as fs from "fs";
const lectures = fs.readdirSync("./src/content/lectures");
const coursework = fs.readdirSync("./src/content/coursework");
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
publicDir: "src/assets",
build: {
target: ["es2020"],
},
resolve: {
mainFields: ["module"],
},
plugins: [
analog({
content: {
highlighter: "prism",
markedOptions: {
extensions: [
{
hooks: {
postprocess(html: string) {
// markedHighlight overrides the mermaid renderer and outputs
// <pre><code class="language-mermaid"> instead of <pre class="mermaid">.
// Convert it back so mermaid.js can find and render these blocks.
return html.replace(
/<pre><code class="language-mermaid">([\s\S]*?)\n<\/code><\/pre>/g,
(_, code) =>
`<pre class="mermaid">${code
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, '"')
.replace(/'/g, "'")}</pre>`,
);
},
},
},
],
},
},
prerender: {
routes: async () => [
"/",
"/lectures",
...lectures.map((post) => `/lectures/${post.replace(".md", "")}`),
...coursework.map((post) => `/work/${post.replace(".md", "")}`),
"/work",
"/team",
"/resources",
],
sitemap: {
host: "https://cscc09.com",
},
},
}),
],
test: {
globals: true,
environment: "jsdom",
setupFiles: ["src/test.ts"],
include: ["**/*.spec.ts"],
},
define: {
"import.meta.vitest": mode !== "production",
},
}));