forked from solidjs/solid-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
100 lines (92 loc) · 2.23 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
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
import { defineConfig } from "@solidjs/start/config";
import remarkFrontmatter from "remark-frontmatter";
import rehypeRaw from "rehype-raw";
import { nodeTypes } from "@mdx-js/mdx";
import remarkGfm from "remark-gfm";
import remarkExpressiveCode, {
ExpressiveCodeTheme,
} from "remark-expressive-code";
import rehypeSlug from "rehype-slug";
import rehypeAutoLinkHeadings from "rehype-autolink-headings";
// @ts-expect-error missing types
import pkg from "@vinxi/plugin-mdx";
const { default: vinxiMdx } = pkg;
function docsTree() {
const virtualModuleId = "solid:collection/tree";
const resolveVirtualModuleId = "\0" + virtualModuleId;
return {
name: "solid:collection/tree",
resolveId(id: string) {
if (id === virtualModuleId) {
return resolveVirtualModuleId;
}
},
async load(id: string) {
if (id === resolveVirtualModuleId) {
const tree = await import(`${process.cwd()}/.solid/tree`);
return `export default ${JSON.stringify(tree, null, 2)}`;
}
},
};
}
function docsEntries() {
const virtualModuleId = "solid:collection/entries";
const resolveVirtualModuleId = "\0" + virtualModuleId;
return {
name: "solid:collection/entries",
resolveId(id: string) {
if (id === virtualModuleId) {
return resolveVirtualModuleId;
}
},
async load(id: string) {
if (id === resolveVirtualModuleId) {
const entries = await import(`${process.cwd()}/.solid/entries`);
return `export default ${JSON.stringify(entries, null, 2)}`;
}
},
};
}
export default defineConfig({
start: {
server: {
preset: "netlify",
},
extensions: ["mdx", "md"],
},
plugins: [
docsTree(),
docsEntries(),
vinxiMdx.withImports({})({
define: {
"import.meta.env": `'import.meta.env'`,
},
jsx: true,
jsxImportSource: "solid-js",
providerImportSource: "solid-mdx",
rehypePlugins: [
[
rehypeRaw,
{
passThrough: nodeTypes,
},
],
[rehypeSlug],
[rehypeAutoLinkHeadings],
],
remarkPlugins: [
remarkFrontmatter,
remarkGfm,
[
remarkExpressiveCode,
{
themes: ["min-light", "material-theme-ocean"],
themeCSSSelector: (theme: ExpressiveCodeTheme) =>
`[data-theme="${theme.name}"]`,
},
],
],
}),
{ enforce: "pre" },
],
});