Skip to content

Commit 91f9643

Browse files
committed
electron building setup
1 parent 2ce4acd commit 91f9643

10 files changed

Lines changed: 111 additions & 24 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ node_modules
1111
dist
1212
dist-ssr
1313
*.local
14+
release
1415

1516
# Editor directories and files
1617
.vscode/*

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Consistently list all task-based targets as phony
2-
.PHONY: all install test-e2e test-unit lint run check debug-e2e
2+
.PHONY: all install test-e2e test-unit build-exe lint run check debug-e2e
33

44
all: check
55

@@ -13,6 +13,14 @@ test-e2e:
1313
test-unit:
1414
npm run test:unit
1515

16+
build-exe:
17+
npm run build:exe
18+
@echo "Cosmos: Executable generated in the /release folder."
19+
20+
build-linux:
21+
npm run build:linux
22+
@echo "Cosmos: Linux AppImage generated in the /release folder."
23+
1624
lint:
1725
npm run lint
1826

dist-electron/main.js

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
1-
import { BrowserWindow, app } from "electron";
2-
import path from "node:path";
3-
import { fileURLToPath } from "node:url";
1+
import { BrowserWindow as e, app as t } from "electron";
2+
import n from "node:path";
3+
import { fileURLToPath as r } from "node:url";
44
//#region electron/main.ts
5-
var __dirname = path.dirname(fileURLToPath(import.meta.url));
6-
var mainWindow;
7-
function createWindow() {
8-
mainWindow = new BrowserWindow({
5+
var i = n.dirname(r(import.meta.url)), a;
6+
function o() {
7+
a = new e({
98
width: 1280,
109
height: 720,
1110
minWidth: 800,
1211
minHeight: 600,
1312
title: "Cosmos Engine",
14-
icon: path.join(__dirname, "../build/cosmos.png"),
13+
icon: n.join(i, "../dist/cosmos.png"),
1514
backgroundColor: "#121212",
16-
autoHideMenuBar: true,
15+
autoHideMenuBar: !0,
1716
webPreferences: {
18-
nodeIntegration: true,
19-
contextIsolation: false,
20-
webSecurity: false
17+
nodeIntegration: !0,
18+
contextIsolation: !1,
19+
webSecurity: !1
2120
}
22-
});
23-
if (process.env.VITE_DEV_SERVER_URL) mainWindow.loadURL(process.env.VITE_DEV_SERVER_URL);
24-
else mainWindow.loadFile(path.join(__dirname, "../dist/index.html"));
21+
}), process.env.VITE_DEV_SERVER_URL ? a.loadURL(process.env.VITE_DEV_SERVER_URL) : a.loadFile(n.join(i, "../dist/index.html"));
2522
}
26-
app.whenReady().then(createWindow);
27-
app.on("window-all-closed", () => {
28-
if (process.platform !== "darwin") app.quit();
29-
});
30-
app.on("activate", () => {
31-
if (BrowserWindow.getAllWindows().length === 0) createWindow();
23+
t.whenReady().then(o), t.on("window-all-closed", () => {
24+
process.platform !== "darwin" && t.quit();
25+
}), t.on("activate", () => {
26+
e.getAllWindows().length === 0 && o();
3227
});
3328
//#endregion

electron/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function createWindow() {
1515
minWidth: 800,
1616
minHeight: 600,
1717
title: "Cosmos Engine",
18-
icon: path.join(__dirname, '../build/cosmos.png'),
18+
icon: path.join(__dirname, '../dist/cosmos.png'),
1919
backgroundColor: '#121212',
2020
autoHideMenuBar: true,
2121
webPreferences: {

package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"test:unit": "vitest run",
1515
"app:build": "npm run build && electron-builder",
1616
"app:preview": "electron .",
17+
"build:exe": "vite build && electron-builder --win",
18+
"build:linux": "vite build && electron-builder --linux",
1719
"prepare": "husky"
1820
},
1921
"dependencies": {
@@ -49,5 +51,23 @@
4951
"typescript-eslint": "^8.58.0",
5052
"vite": "^8.0.4",
5153
"vite-plugin-electron": "^0.29.1"
54+
},
55+
"build": {
56+
"appId": "com.cosmos.engine",
57+
"productName": "Cosmos Engine",
58+
"directories": {
59+
"output": "release"
60+
},
61+
"files": [
62+
"dist/**/*",
63+
"dist-electron/**/*"
64+
],
65+
"win": {
66+
"target": "nsis"
67+
},
68+
"linux": {
69+
"target": "AppImage",
70+
"category": "Development"
71+
}
5272
}
5373
}

public/cosmos.icns

686 KB
Binary file not shown.

public/cosmos.ico

4.19 KB
Binary file not shown.

public/cosmos.png

375 KB
Loading

public/cosmos.svg

Lines changed: 63 additions & 0 deletions
Loading

src/components/editor/EditorToolbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export function EditorToolbar({
184184
}}
185185
>
186186
<img
187-
src="/minecraft.svg"
187+
src="./minecraft.svg"
188188
alt="Minecraft"
189189
width={16}
190190
height={16}

0 commit comments

Comments
 (0)