-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
53 lines (50 loc) · 1.28 KB
/
vite.config.ts
File metadata and controls
53 lines (50 loc) · 1.28 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
import funstackStatic from "@funstack/static";
import mdx from "@mdx-js/rollup";
import rehypeShikiFromHighlighter from "@shikijs/rehype/core";
import react from "@vitejs/plugin-react";
import rehypeSlug from "rehype-slug";
import { defineConfig, type UserConfig } from "vite";
import { getHighlighter, shikiThemes } from "./src/lib/shiki";
export default defineConfig(async () => {
const highlighter = await getHighlighter();
const config: UserConfig = {
plugins: [
funstackStatic({
entries: "./src/entries.tsx",
ssr: true,
build: "./src/build.ts",
}),
{
// to make .mdx loading lazy
name: "vite-plugin-mdx-lazy",
load(id) {
if (id.endsWith(".mdx")) {
return `
import { lazy } from "react";
export default lazy(() => import("${id}?lazy"));
`;
}
return undefined;
},
},
{
enforce: "pre",
...mdx({
rehypePlugins: [
rehypeSlug,
[
rehypeShikiFromHighlighter,
highlighter,
{
themes: shikiThemes,
},
],
],
}),
},
react({ include: /\.(jsx|js|mdx|md|tsx|ts)$/ }),
],
base: "/",
};
return config;
});