Add Electron desktop app with macOS DMG and Windows installer support

- Add electron/main.js as the Electron main process
- Configure electron-builder for macOS (x64 + arm64 DMG) and Windows (x64 + arm64 NSIS installer)
- Add build scripts: electron:build (mac), electron:build:win (windows)
- Set vite base to './' for file:// protocol compatibility in Electron
This commit is contained in:
Anil Matcha 2026-03-18 11:45:23 +05:30
commit 6e0b18cd22
4 changed files with 5034 additions and 649 deletions

59
electron/main.js Normal file
View file

@ -0,0 +1,59 @@
import { app, BrowserWindow, shell } from 'electron';
import { fileURLToPath } from 'url';
import path from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
let mainWindow;
function createWindow() {
mainWindow = new BrowserWindow({
width: 1440,
height: 900,
minWidth: 1024,
minHeight: 640,
webPreferences: {
webSecurity: false, // Allow file:// origin to call external APIs
contextIsolation: true,
nodeIntegration: false,
},
titleBarStyle: 'hiddenInset',
backgroundColor: '#0d0d0d',
show: false,
title: 'Open Higgsfield AI',
});
const indexPath = path.join(__dirname, '../dist/index.html');
mainWindow.loadFile(indexPath);
// Open external links in the system browser
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
shell.openExternal(url);
return { action: 'deny' };
});
mainWindow.once('ready-to-show', () => {
mainWindow.show();
});
mainWindow.on('closed', () => {
mainWindow = null;
});
}
app.whenReady().then(() => {
createWindow();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});

4283
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -2,15 +2,67 @@
"name": "open-higgsfield-ai",
"description": "Open-source alternative to Higgsfield AI — AI image generation and cinema studio with 20+ models",
"private": true,
"version": "0.0.0",
"version": "1.0.0",
"type": "module",
"main": "electron/main.js",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
"preview": "vite preview",
"electron:dev": "vite build && electron .",
"electron:build": "vite build && electron-builder --mac",
"electron:build:dmg": "vite build && electron-builder --mac dmg",
"electron:build:win": "vite build && electron-builder --win"
},
"build": {
"appId": "ai.higgsfield.open",
"productName": "Open Higgsfield AI",
"copyright": "Copyright © 2025",
"files": [
"dist/**/*",
"electron/**/*"
],
"mac": {
"category": "public.app-category.graphics-design",
"icon": "public/banner.png",
"target": [
{
"target": "dmg",
"arch": [
"x64",
"arm64"
]
}
]
},
"dmg": {
"title": "Open Higgsfield AI",
"backgroundColor": "#0d0d0d",
"window": {
"width": 540,
"height": 380
}
},
"win": {
"icon": "public/banner.png",
"target": [
{
"target": "nsis",
"arch": ["x64", "arm64"]
}
]
},
"nsis": {
"oneClick": true,
"perMachine": false,
"allowToChangeInstallationDirectory": false,
"deleteAppDataOnUninstall": false
}
},
"devDependencies": {
"autoprefixer": "^10.4.24",
"electron": "^33.4.11",
"electron-builder": "^25.1.8",
"postcss": "^8.5.6",
"tailwindcss": "^4.1.18",
"vite": "^5.4.0"

View file

@ -2,6 +2,7 @@ import { defineConfig } from 'vite';
import tailwindcss from '@tailwindcss/vite';
export default defineConfig({
base: './',
plugins: [
tailwindcss(),
],