-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.config.ts
66 lines (61 loc) · 1.42 KB
/
app.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 { createApp, resolve } from 'vinxi';
import { BaseFileSystemRouter, cleanPath } from 'vinxi/fs-router';
import reactPlugin from '@vitejs/plugin-react';
import { serverFunctions } from '@vinxi/server-functions/plugin';
class FileRouter extends BaseFileSystemRouter {
toPath(src: any): string {
const path = cleanPath(src, this.config)
.slice(1)
.replace('index', '')
.replace(/\[([^\/]+)\]/g, (_, m) => {
if (m.length > 3 && m.startsWith('...')) {
return `*${m.slice(3)}`;
}
return `:${m}`;
});
return `/${path}`;
}
toRoute(src: any) {
const path = this.toPath(src);
return {
$component: {
src,
pick: ['default'],
},
path,
filePath: src,
};
}
}
export default createApp({
routers: [
{
type: 'spa',
name: 'client',
handler: './index.html',
plugins: () => [reactPlugin(), serverFunctions.client()],
routes: (router, app) => {
return new FileRouter(
{
dir: resolve.absolute('./src/pages', router.root!),
extensions: ['tsx', 'jsx', 'ts', 'js'],
},
router,
app,
);
},
},
{
type: 'http',
name: 'api',
handler: './src/api.ts',
base: '/api',
},
{
type: 'static',
name: 'static',
dir: './public',
},
serverFunctions.router(),
],
});