forked from ckangwen/vite-plugin-pages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
77 lines (71 loc) · 1.76 KB
/
types.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
/**
* https://github.com/brattonross/vite-plugin-voie/blob/main/packages/vite-plugin-voie/src/options.ts
*
* This source code is licensed under the MIT license found in the
* LICENSE file at
* https://github.com/brattonross/vite-plugin-voie/blob/main/LICENSE
*/
export type ImportMode = 'sync' | 'async'
export type ImportModeResolveFn = (filepath: string) => ImportMode
export interface Route {
name?: string
path: string
props?: boolean
component: string
children?: Route[]
meta?: Record<string, unknown>
}
export interface PageDirOptions {
dir: string
baseRoute: string
}
/**
* Plugin options.
*/
interface Options {
/**
* Relative path to the directory to search for page components.
* @default 'src/pages'
*/
pagesDir: string | string[] | PageDirOptions[]
/**
* Valid file extensions for page components.
* @default ['vue', 'js']
*/
extensions: string[]
/**
* List of path globs to exclude when resolving pages.
*/
exclude: string[]
/**
* Import routes directly or as async components
* @default 'async'
*/
importMode: ImportMode | ImportModeResolveFn
/**
* Sync load top level index file
* @default true
*/
syncIndex: boolean
/**
* Set default route block parser, or use `<route lang=xxx>` in SFC route block
* @default 'json5'
*/
routeBlockLang: 'json5' | 'json' | 'yaml'
/**
* Extend route records
*/
extendRoute?: (route: Route, parent: Route | undefined) => Route | void
}
export type UserOptions = Partial<Options>
export interface ResolvedOptions extends Options {
/**
* Resolves to the `root` value from Vite config.
* @default config.root
*/
root: string
/**
* Page Dir as a normalized array of PageDirOptions
*/
pagesDirOptions: PageDirOptions[]
}