-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathconfig.ts
79 lines (60 loc) · 1.52 KB
/
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
import { workspace } from 'vscode'
export function getConfig<T>(key: string, v?: T) {
return workspace.getConfiguration().get(`vite.${key}`, v)
}
export const Config = {
get root() {
return workspace.workspaceFolders?.[0]?.uri?.fsPath || ''
},
get autoStart() {
return getConfig('autoStart', true)
},
get browser() {
return getConfig<'system' | 'embedded'>('browserType', 'embedded')!
},
get pingInterval() {
return getConfig('pingInterval', 200)!
},
get maximumTimeout() {
return getConfig('maximumTimeout', 30_000)!
},
get showTerminal() {
return getConfig('showTerminal', false)!
},
get notifyOnStarted() {
return getConfig('notifyOnStarted', true)!
},
get port() {
return getConfig('port', 4000)!
},
get host() {
return getConfig('host', 'localhost')!
},
get https() {
return getConfig('https', false)!
},
get base() {
return getConfig('base', '')!
},
get vitepress() {
return getConfig('vitepress', true)!
},
get vitepressAutoRouting() {
return getConfig('vitepressAutoRouting', false)!
},
get vitepressBase() {
return getConfig('vitepressBase', '')!
},
get buildCommand() {
return getConfig('buildCommand', 'npm run build')!
},
get devCommand(): string | undefined {
return getConfig('devCommand')
},
get open(): boolean {
return getConfig('open') ?? true
},
}
export function composeUrl(port: number) {
return `${Config.https ? 'https' : 'http'}://${Config.host}:${port}${Config.base}`
}