-
Notifications
You must be signed in to change notification settings - Fork 12
/
fuse.ts
73 lines (66 loc) · 1.67 KB
/
fuse.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
import { fusebox, sparky } from "fuse-box";
class Context {
isProduction;
runServer;
getMainConfig() {
return fusebox({
output: "dist/main/$name-$hash",
target: "electron",
homeDir: "src/main",
entry: "main.ts",
useSingleBundle: true,
dependencies: { ignoreAllExternal: true },
logging: { level: "succinct" },
cache: {
enabled: true,
root: ".cache/main"
}
});
}
launch(handler) {
handler.onComplete(output => {
output.electron.handleMainProcess();
});
}
getRendererConfig() {
return fusebox({
output: "dist/renderer/$name-$hash",
target: "electron",
homeDir: "src/renderer",
entry: "index.ts",
dependencies: { include: ["tslib"] },
logging: { level: "succinct" },
webIndex: {
publicPath: "./",
template: "src/renderer/index.html"
},
cache: {
enabled: false,
root: ".cache/renderere"
},
devServer: {
httpServer: false,
hmrServer: { port: 7878 }
}
});
}
}
const { task, rm } = sparky<Context>(Context);
task("default", async ctx => {
await rm("./dist");
const rendererConfig = ctx.getRendererConfig();
await rendererConfig.runDev();
const electronMain = ctx.getMainConfig();
await electronMain.runDev(handler => ctx.launch(handler));
});
task("dist", async ctx => {
await rm("./dist");
const rendererConfig = ctx.getRendererConfig();
await rendererConfig.runProd({ uglify: false });
const electronMain = ctx.getMainConfig();
await electronMain.runProd({
uglify: true,
manifest: true,
handler: handler => ctx.launch(handler)
});
});