-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
66 lines (62 loc) · 1.99 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
import mdx from '@mdx-js/rollup';
import { transformerNotationDiff } from '@shikijs/transformers';
import react from '@vitejs/plugin-react';
import type { Options as RemarkRehypeOptions } from 'mdast-util-to-hast';
import { rehypePrettyCode } from 'rehype-pretty-code';
import remarkGfm from 'remark-gfm';
import remarkRehype from 'remark-rehype';
import vike from 'vike/plugin';
import { UserConfig } from 'vite';
// Inspired by https://github.com/brillout/docpress/blob/main/src/vite.config.ts
const prettyCode = [
rehypePrettyCode,
{ theme: 'github-light', transformers: [transformerNotationDiff({ matchAlgorithm: 'v3' })] },
];
const rehypePlugins: any = [prettyCode]; // eslint-disable-line @typescript-eslint/no-explicit-any
const remarkPlugins = [
[
remarkRehype,
{
footnoteLabelTagName: 'span',
footnoteLabel: ' ',
footnoteBackLabel: i => `${i + 1}`,
clobberPrefix: '',
} satisfies RemarkRehypeOptions,
] as any, // eslint-disable-line @typescript-eslint/no-explicit-any
remarkGfm,
];
const ReactCompilerConfig = {
target: '18',
};
const config: UserConfig = {
plugins: [
// Both `enforce: 'pre'` and React `include` are needed to achieve HMR when modifying .mdx files
// See https://github.com/mdx-js/mdx/pull/2474
{
enforce: 'pre',
...mdx({
providerImportSource: '@mdx-js/react',
rehypePlugins,
remarkPlugins,
}),
},
react({
include: /\.(jsx|js|mdx|md|tsx|ts)$/,
babel: {
plugins: [['babel-plugin-react-compiler', ReactCompilerConfig]],
},
}),
vike({
// Doesn't seem to work anymore with `vike-react`; instead we re-implement it with a meta refresh tag (also `redirect` doesn't support SSG anyways)
//redirects: INVISIBLE_REDIRECTIONS,
}),
],
build: {
modulePreload: {
// See https://github.com/quasarframework/quasar/issues/12866
polyfill: true,
},
},
};
// eslint-disable-next-line import/no-default-export
export default config;