-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
106 lines (102 loc) · 2.54 KB
/
vite.config.ts
File metadata and controls
106 lines (102 loc) · 2.54 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
94
95
96
97
98
99
100
101
102
103
104
105
106
import { rmSync } from "node:fs";
import { resolve } from "node:path";
import mdx from "@mdx-js/rollup";
import githubDark from "@shikijs/themes/github-dark";
import githubLight from "@shikijs/themes/github-light";
import tailwindcss from "@tailwindcss/vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import viteReact from "@vitejs/plugin-react";
import rehypePrettyCode from "rehype-pretty-code";
import remarkGfm from "remark-gfm";
import { createHighlighterCore } from "shiki/core";
import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
import { defineConfig } from "vite";
const options = {
getHighlighter: () =>
createHighlighterCore({
themes: [githubDark, githubLight],
langs: [import("@shikijs/langs/tsx")],
engine: createJavaScriptRegexEngine(),
}),
theme: {
light: "github-light",
dark: "github-dark",
},
};
export default defineConfig({
resolve: {
tsconfigPaths: true,
},
plugins: [
{
enforce: "pre",
...mdx({
remarkPlugins: [remarkGfm],
rehypePlugins: [[rehypePrettyCode, options]],
}),
},
tanstackStart({
prerender: {
enabled: true,
crawlLinks: false,
},
pages: [
{
path: "/",
prerender: {
outputPath: "/index.html",
enabled: true,
crawlLinks: false,
},
},
{
path: "/tools",
prerender: {
outputPath: "/tools.html",
enabled: true,
crawlLinks: false,
},
},
{
path: "/docs",
prerender: {
outputPath: "/docs.html",
enabled: true,
crawlLinks: true,
},
},
],
spa: {
enabled: true,
prerender: {
outputPath: "/index.html",
enabled: true,
crawlLinks: false,
},
},
}),
viteReact({ include: /\.(mdx|jsx|tsx)$/ }),
tailwindcss(),
],
build: {
rollupOptions: {
plugins: [
{
name: "exclude-tools-collection",
closeBundle() {
if (this.meta.watchMode) return;
const dist = resolve(process.cwd(), "dist/client");
rmSync(resolve(dist, "tools-collection"), { recursive: true, force: true });
rmSync(resolve(dist, "tools.json"), { force: true });
},
},
],
},
},
server: {
port: 4001,
},
define: {
COMMIT_SHA: `"${process.env.GITHUB_SHA?.slice(0, 7).toString()}"`,
},
});