-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.docs.config.mts
More file actions
100 lines (86 loc) · 3.5 KB
/
vite.docs.config.mts
File metadata and controls
100 lines (86 loc) · 3.5 KB
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 vue from '@vitejs/plugin-vue';
import { defineConfig } from 'vite';
import { fileURLToPath, URL } from 'url';
const getAlphaChunkSuffix = (id: string) => {
const fileName =
id
.split('/')
.at(-1)
?.replace(/\.[^.]+$/u, '')
.toLowerCase() ?? '';
const firstCharacter = fileName.charAt(0);
if (firstCharacter >= 'a' && firstCharacter <= 'f') {
return 'a-f';
}
if (firstCharacter >= 'g' && firstCharacter <= 'm') {
return 'g-m';
}
if (firstCharacter >= 'n' && firstCharacter <= 's') {
return 'n-s';
}
return 't-z';
};
export default defineConfig({
root: 'apps/docs',
plugins: [vue()],
resolve: {
alias: [
{ find: '@core', replacement: fileURLToPath(new URL('./packages/vueforge/src', import.meta.url)) },
{ find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) },
],
},
build: {
outDir: '../../dist/docs',
emptyOutDir: true,
chunkSizeWarningLimit: 650,
rollupOptions: {
output: {
manualChunks(id) {
const normalizedId = id.replace(/\\/g, '/');
if (normalizedId.includes('/src/docs/DocsExamplePreview.vue')) {
return 'docs-preview-runtime';
}
if (normalizedId.includes('/packages/vueforge/src/components/')) {
return 'docs-preview-core';
}
if (normalizedId.includes('/packages/layouts/src/components/')) {
return 'docs-preview-layouts';
}
if (normalizedId.includes('/docs/components/')) {
return `docs-content-components-${getAlphaChunkSuffix(normalizedId)}`;
}
if (
normalizedId.includes('/docs/guides/') ||
normalizedId.includes('/docs/recipes/') ||
normalizedId.includes('/docs/audits/') ||
normalizedId.includes('/docs/accessibility/') ||
normalizedId.includes('/docs/contributing/') ||
normalizedId.includes('/docs/migrations/')
) {
return 'docs-content-guides';
}
if (
normalizedId.includes('/src/docs/docs-markdown.ts') ||
normalizedId.includes('/src/docs/docs-features.ts') ||
normalizedId.includes('/src/docs/docs-structure.ts') ||
normalizedId.includes('/docs/browser-support.md') ||
normalizedId.includes('/docs/theming.md') ||
normalizedId.includes('/docs/api-conventions.md')
) {
return 'docs-content-core';
}
if (
normalizedId.includes('/node_modules/vue/') ||
normalizedId.includes('/node_modules/vue-router/') ||
normalizedId.includes('/node_modules/@vue/')
) {
return 'vue-vendor';
}
if (normalizedId.includes('/node_modules/@codemonster-ru/vue-codeblock/')) {
return 'codeblock-vendor';
}
},
},
},
},
});