forked from joshwcomeau/beatmapper
-
Notifications
You must be signed in to change notification settings - Fork 10
/
vite.config.ts
64 lines (59 loc) · 1.62 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
import { fileURLToPath } from "node:url";
import type { Pluggable } from "unified";
import { type Plugin, type UserConfig, defineConfig } from "vite";
import { default as mdx } from "@mdx-js/rollup";
import { default as react } from "@vitejs/plugin-react";
import { VitePWA as pwa } from "vite-plugin-pwa";
import { default as rehypeMdxImportMedia } from "rehype-mdx-import-media";
import { default as rehypeSlug } from "rehype-slug";
import { default as remarkFrontmatter } from "remark-frontmatter";
import { default as remarkGfm } from "remark-gfm";
import { default as remarkMdxFrontmatter } from "remark-mdx-frontmatter";
import { remarkMdxToc } from "remark-mdx-toc";
import packageJson from "./package.json";
function markdown() {
return {
enforce: "pre",
...mdx({
providerImportSource: "@mdx-js/react",
remarkPlugins: [
remarkGfm,
remarkFrontmatter,
[remarkMdxFrontmatter, { name: "frontMatter" }],
[remarkMdxToc, { name: "tableOfContents" }] as Pluggable,
//
],
rehypePlugins: [
rehypeSlug,
rehypeMdxImportMedia,
//
],
}),
} as Plugin;
}
// https://vitejs.dev/config/
export default defineConfig((ctx) => {
return {
plugins: [react(), markdown(), pwa({ registerType: "autoUpdate" })],
define: {
global: "window",
version: `\"${packageJson.version}\"`,
},
resolve: {
alias: {
$: fileURLToPath(new URL("./src", import.meta.url)),
},
},
assetsInclude: ["**/*.glsl"],
build: {
commonjsOptions: { transformMixedEsModules: true }, // Change
},
optimizeDeps: {
esbuildOptions: {
loader: {
".js": "jsx",
},
},
},
} as UserConfig;
});