feat: Added macos and windows electron builds
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -10,4 +10,5 @@ node_modules
|
||||
.output
|
||||
vite.config.js.timestamp-*
|
||||
vite.config.ts.timestamp-*
|
||||
/config/*.sqlite
|
||||
/config/*.sqlite
|
||||
/dist
|
||||
22
build.config.json
Normal file
22
build.config.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"appId": "me.aleksilassila.reiverr",
|
||||
"productName": "Reiverr",
|
||||
"directories": {
|
||||
"output": "dist"
|
||||
},
|
||||
"mac": {
|
||||
"asar": false
|
||||
},
|
||||
"win": {
|
||||
"asar": false,
|
||||
"target": "msi"
|
||||
},
|
||||
"asar": false,
|
||||
"files": [
|
||||
"src/electron.cjs",
|
||||
{
|
||||
"from": "build",
|
||||
"to": "build"
|
||||
}
|
||||
]
|
||||
}
|
||||
1990
package-lock.json
generated
1990
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -5,11 +5,13 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/aleksilassila/reiverr"
|
||||
},
|
||||
"main": "src/electron.cjs",
|
||||
"scripts": {
|
||||
"dev": "vite dev --host",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"deploy": "PORT=9494 NODE_ENV=production node build/",
|
||||
"deploy:electron": "vite build && electron-builder -mw --x64 --config build.config.json; electron-builder -m --arm64 --config build.config.json",
|
||||
"test": "playwright test",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
@@ -31,6 +33,8 @@
|
||||
"@typescript-eslint/parser": "^5.45.0",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"classnames": "^2.3.2",
|
||||
"electron": "^26.1.0",
|
||||
"electron-builder": "^24.6.3",
|
||||
"eslint": "^8.28.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-svelte": "^2.26.0",
|
||||
|
||||
51
src/electron.cjs
Normal file
51
src/electron.cjs
Normal file
@@ -0,0 +1,51 @@
|
||||
process.env.PORT = '9494';
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
|
||||
(async () => {
|
||||
await import('../build/index.js');
|
||||
// const serveURL = serve({ directory: '.' });
|
||||
const port = process.env.PORT || 5173;
|
||||
let mainWindow;
|
||||
|
||||
const createWindow = () => {
|
||||
if (!mainWindow) {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1200,
|
||||
height: 800,
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mainWindow.once('close', () => {
|
||||
mainWindow = null;
|
||||
});
|
||||
|
||||
loadSite(port);
|
||||
|
||||
return mainWindow;
|
||||
};
|
||||
|
||||
function loadSite(port) {
|
||||
mainWindow.loadURL(`http://localhost:${port}`).catch((e) => {
|
||||
console.log('Error loading URL, retrying', e);
|
||||
setTimeout(() => {
|
||||
loadSite(port);
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
app.on('activate', () => {
|
||||
if (!mainWindow) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') app.quit();
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user