-
Notifications
You must be signed in to change notification settings - Fork 14
/
vite.sim.w
51 lines (44 loc) · 1.29 KB
/
vite.sim.w
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
bring cloud;
bring sim;
bring util;
bring fs;
bring "./vite-types.w" as vite_types;
inflight interface DevOutput {
inflight url(): str;
inflight kill(): void;
}
pub class Vite_sim {
pub url: str;
new(props: vite_types.ViteProps) {
let state = new sim.State();
this.url = state.token("url");
let cliFilename = Vite_sim.cliFilename();
let homeEnv = util.tryEnv("HOME") ?? "";
let pathEnv = util.tryEnv("PATH") ?? "";
let openBrowser = (() => {
if util.env("WING_IS_TEST") == "true" {
return false;
}
return props.openBrowser ?? false;
})();
new cloud.Service(inflight () => {
let output = Vite_sim.dev({
root: props.root,
publicEnv: props.publicEnv ?? {},
generateTypeDefinitions: props.generateTypeDefinitions ?? true,
publicEnvName: props.publicEnvName ?? "wing",
typeDefinitionsFilename: props.typeDefinitionsFilename ?? ".winglibs/wing-env.d.ts",
cliFilename: cliFilename,
homeEnv: homeEnv,
pathEnv: pathEnv,
openBrowser: openBrowser,
});
state.set("url", output.url());
return () => {
output.kill();
};
});
}
extern "./vite.cjs" static cliFilename(): str;
extern "./vite.cjs" static inflight dev(options: Json): DevOutput;
}