-
Notifications
You must be signed in to change notification settings - Fork 14
/
capacitor.config.ts
47 lines (42 loc) · 1.12 KB
/
capacitor.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
import { CapacitorConfig } from "@capacitor/cli";
import os, { NetworkInterfaceInfo } from "node:os";
function localIpAddress() {
const interfaces = Object.values(os.networkInterfaces()).filter(
(iface) => iface !== undefined,
) as NetworkInterfaceInfo[][];
const aliases = interfaces
.filter((iface) =>
iface.some((alias) => alias.family === "IPv4" && !alias.internal),
)
.map((iface) => {
iface = iface.filter(
(alias) => alias.family === "IPv4" && !alias.internal,
);
return iface;
})
.flat();
const ipAddress = aliases.find((alias) => !alias.address.startsWith("172"))
?.address;
if (!ipAddress) {
throw new Error("No suitable network interface found.");
}
return ipAddress;
}
const isDev = process.env.NODE_ENV === "development" || false;
if (isDev) {
console.log(localIpAddress());
}
export default {
appId: "app.dumpus.app",
appName: "Dumpus",
...(isDev
? {
server: {
url: `http://${localIpAddress()}:3000`,
cleartext: true,
},
}
: {
webDir: "dist",
}),
} satisfies CapacitorConfig;