-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.js
98 lines (90 loc) · 2.13 KB
/
vite.config.js
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
import { defineConfig } from "vite";
import { readFileSync } from "node:fs";
import preact from "@preact/preset-vite";
import { resolve } from "node:path";
import mdx from "@mdx-js/rollup";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import rehypeKatex from "rehype-katex";
import remarkMath from "remark-math";
import rehypeShiki from "@shikijs/rehype";
import esbuild from "rollup-plugin-esbuild";
import styleX from "vite-plugin-stylex";
export const build = {
assetsInlineLimit: 0,
minify: "esbuild",
rollupOptions: {
input: {
main: resolve(__dirname, "index.html"),
},
plugins: [
esbuild({
target: "esnext",
jsxFactory: "h",
jsxFragment: "Fragment",
}),
],
},
};
export const plugins = [
preact({
include: ["**/*.res.mjs"],
}),
styleX(),
nodePolyfills({
// Whether to polyfill `node:` protocol imports.
protocolImports: true,
}),
mdx({
rehypePlugins: [
// rehypeSlug,
rehypeKatex,
// rehypeInferReadingTimeMeta,
// rehypeCodeTitles,
[
rehypeShiki,
{
// or `theme` for a single theme
// themes for light and dark themes
theme: "rose-pine",
},
],
],
remarkPlugins: [remarkMath],
providerImportSource: "@mdx-js/preact",
}),
// use a different html file for dev/prod
{
name: "index-html-env",
async transformIndexHtml() {
const isProd = process.env.NODE_ENV === "production";
if (!isProd) {
return readFileSync("index_dev.html", "utf8");
}
},
},
// critical css inlining doesnt work right
//TODO: figure this out later??
// {
// name: "inline-critical",
// async transformIndexHtml(html) {
// return await InlineCSS(html, "test/");
// },
// },
];
export default defineConfig({
base: "./",
esbuild: {
target: "esnext",
jsxFactory: "h",
jsxFragment: "Fragment",
jsxInject: `import { h, Fragment } from 'preact'`,
},
build,
test: {
globals: false,
environment: "jsdom",
root: __dirname,
setupFiles: ["./vitest-setup.js"],
},
plugins,
});