forked from pocket-id/website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
73 lines (62 loc) · 1.86 KB
/
vite.config.ts
File metadata and controls
73 lines (62 loc) · 1.86 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
import tailwindcss from '@tailwindcss/vite';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import fs from 'node:fs';
import path from 'node:path';
function generateLlmsTxt() {
return {
name: 'generate-llms-txt',
buildStart() {
const docsDir = 'docs';
let content = '# Pocket ID Documentation\n\n';
interface ReadMarkdownFiles {
(dir: string): void;
}
interface FileStat {
isDirectory(): boolean;
}
function readMarkdownFiles(dir: string): void {
const files: string[] = fs.readdirSync(dir);
for (const file of files) {
const filePath: string = path.join(dir, file);
const stat: FileStat = fs.statSync(filePath);
if (stat.isDirectory()) {
readMarkdownFiles(filePath);
} else if (file.endsWith('.md')) {
const relativePath: string = path.relative('docs', filePath);
const fileContent: string = fs.readFileSync(filePath, 'utf-8');
content += `## ${relativePath}\n\n`;
content += fileContent;
content += '\n\n---\n\n';
}
}
}
if (fs.existsSync(docsDir)) {
readMarkdownFiles(docsDir);
// Write to static directory
if (!fs.existsSync('static')) {
fs.mkdirSync('static');
}
fs.writeFileSync('static/llms.txt', content);
console.log('✅ Generated llms.txt with all documentation');
}
},
};
}
export default defineConfig({
plugins: [tailwindcss(), generateLlmsTxt(), sveltekit()],
server: {
fs: {
allow: ['..', './docs'],
},
},
build: {
rollupOptions: {
output: {
manualChunks: {
icons: ['@lucide/svelte'],
},
},
},
},
});