UNPKG

create-kaplay-game

Version:

CLI to scaffold an Electron+Vite+Kaplay game project.

32 lines (27 loc) 780 B
const { app, BrowserWindow } = require("electron"); const path = require("path"); function createWindow() { const win = new BrowserWindow({ width: 800, height: 600, webPreferences: { preload: path.join(__dirname, "preload.js"), contextIsolation: true, }, }); // In dev, load Vite dev server. In prod, load index.html if (process.env.NODE_ENV === "development") { win.loadURL("http://localhost:5173"); } else { win.loadFile(path.resolve(__dirname, "../../index.html")); } } app.whenReady().then(() => { createWindow(); app.on("activate", function () { if (BrowserWindow.getAllWindows().length === 0) createWindow(); }); }); app.on("window-all-closed", function () { if (process.platform !== "darwin") app.quit(); });