-
Notifications
You must be signed in to change notification settings - Fork 146
/
Copy pathvite.config.ts
113 lines (109 loc) · 3.24 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
101
102
103
104
105
106
107
108
109
110
111
112
113
import { qwikCity } from '@builder.io/qwik-city/vite';
import { qwikVite } from '@builder.io/qwik/optimizer';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
import autoAPI from './auto-api';
export default defineConfig(async () => {
const { default: rehypePrettyCode } = await import('rehype-pretty-code');
const { visit } = await import('unist-util-visit');
// commented out as doesn't seem to work with import.meta.glob eager:false in preview
// let output: any = {};
// if (!isDev) {
// // Client-specific configuration
// output = {
// // Customize the client build structure
// entryFileNames: ({ name }: any) => {
// if (name.startsWith('entry')) {
// return '[name].mjs';
// }
// return `[name]-[hash].js`;
// },
// chunkFileNames: () => {
// return `[name]-[hash].js`;
// },
// assetFileNames: `build/[name]-[hash].[ext]`,
// };
// }
return {
plugins: [
autoAPI(),
qwikCity({
mdxPlugins: {
rehypeSyntaxHighlight: false,
remarkGfm: true,
rehypeAutolinkHeadings: true,
},
mdx: {
providerImportSource: '~/_state/MDXProvider',
// recmaPlugins: [recmaProvideComponents],
rehypePlugins: [
() => (tree) => {
visit(tree, (node) => {
if (node?.type === 'element' && node?.tagName === 'pre') {
const [codeEl] = node.children;
if (codeEl.tagName !== 'code') {
return;
}
node.__rawString__ = codeEl.children?.[0].value;
}
});
},
[
rehypePrettyCode,
{
theme: 'poimandres',
},
],
() => (tree) => {
visit(tree, (node) => {
if (node?.type === 'element' && node?.tagName === 'figure') {
if (!('data-rehype-pretty-code-figure' in node.properties)) {
return;
}
const preElement = node.children.at(-1);
if (preElement.tagName !== 'pre') {
return;
}
preElement.properties['__rawString__'] = node.__rawString__;
}
});
},
],
},
}),
qwikVite({
lint: false,
tsconfigFileNames: ['tsconfig.app.json'],
client: {
outDir: '../../dist/apps/website/client',
},
ssr: {
outDir: '../../dist/apps/website/server',
},
}),
tsconfigPaths({ root: '../../' }),
],
server: {
fs: {
// Allow serving files from the project root
allow: ['../../'],
},
},
build: {
target: 'es2022',
rollupOptions: {
// output,
},
},
preview: {
headers: {
'Cache-Control': 'public, max-age=600',
},
},
optimizeDeps: {
// Put problematic deps that break bundling here, mostly those with binaries.
// For example ['better-sqlite3'] if you use that in server functions.
exclude: ['shiki'],
},
};
});