Merge pull request #6 from presenton/electron_build_setup
Adds: Electron Builder setup
This commit is contained in:
commit
4df07ffae4
6 changed files with 37 additions and 13 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -176,6 +176,8 @@ dist
|
|||
# Finder (MacOS) folder config
|
||||
.DS_Store
|
||||
|
||||
app_dist
|
||||
|
||||
env
|
||||
.venv
|
||||
__pycache__
|
||||
|
|
|
|||
10
app/main.ts
10
app/main.ts
|
|
@ -7,10 +7,9 @@ import { ChildProcessByStdio } from "child_process";
|
|||
import { localhost } from "./constants";
|
||||
|
||||
var isDev = !app.isPackaged;
|
||||
var baseDir = isDev ? process.cwd() : process.resourcesPath;
|
||||
var resourcesDir = path.join(baseDir, "resources");
|
||||
var fastapiDir = isDev ? path.join(baseDir, "servers/fastapi") : path.join(resourcesDir, "fastapi");
|
||||
var nextjsDir = isDev ? path.join(baseDir, "servers/nextjs") : path.join(resourcesDir, "nextjs");
|
||||
var baseDir = app.getAppPath();
|
||||
var fastapiDir = isDev ? path.join(baseDir, "servers/fastapi") : path.join(baseDir, "resources/fastapi");
|
||||
var nextjsDir = isDev ? path.join(baseDir, "servers/nextjs") : path.join(baseDir, "resources/nextjs");
|
||||
|
||||
var tempDir = app.getPath("temp");
|
||||
var dataDir = app.getPath("userData");
|
||||
|
|
@ -74,8 +73,7 @@ async function stopServers() {
|
|||
|
||||
app.whenReady().then(async () => {
|
||||
createWindow();
|
||||
win?.loadFile(path.join(resourcesDir, "ui/homepage/index.html"));
|
||||
|
||||
win?.loadFile(path.join(baseDir, "resources/ui/homepage/index.html"));
|
||||
win?.webContents.openDevTools();
|
||||
|
||||
createUserConfig(app, {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ export async function startNextJsServer(
|
|||
["run", "dev", "--", "-p", port.toString()],
|
||||
] : [
|
||||
"npx",
|
||||
["next", "start", "--", "-p", port.toString()],
|
||||
["next", "start", "-p", port.toString()],
|
||||
];
|
||||
|
||||
|
||||
|
|
|
|||
20
build.js
Normal file
20
build.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
const builder = require("electron-builder")
|
||||
|
||||
const config = {
|
||||
appId: "ai.presenton",
|
||||
asar: false,
|
||||
directories: {
|
||||
output: "dist",
|
||||
},
|
||||
files: [
|
||||
"resources",
|
||||
"app_dist",
|
||||
"node_modules",
|
||||
],
|
||||
linux: {
|
||||
target: ["AppImage"],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
builder.build({ config })
|
||||
14
package.json
14
package.json
|
|
@ -1,22 +1,26 @@
|
|||
{
|
||||
"name": "presenton_open_source",
|
||||
"main": "dist/main.js",
|
||||
"main": "app_dist/main.js",
|
||||
"version": "0.0.0",
|
||||
"description": "Presenton Open Source",
|
||||
"homepage": "https://presenton.ai",
|
||||
"author": {
|
||||
"name": "Presenton",
|
||||
"email": "contact@presenton.ai"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "tsc && electron --gtk-version=3 .",
|
||||
"start": "tsc && electron-forge start",
|
||||
"package": "tsc && electron-forge package",
|
||||
"make": "tsc && electron-forge make",
|
||||
"setup:env": "npm install && cd servers/fastapi && poetry install && cd ../../servers/nextjs && npm install",
|
||||
"build:ts": "tsc",
|
||||
"build:css": "tailwindcss -i ./resources/ui/assets/tailwind.import.css -o ./resources/ui/assets/tailwind.css",
|
||||
"build:nextjs": "rm -rf resources/nextjs && mkdir -p resources/nextjs && cd servers/nextjs && npm run build && cp -r .next ../../resources/nextjs",
|
||||
"build:nextjs": "rm -rf resources/nextjs && cp -r servers/nextjs resources/nextjs && cd resources/nextjs && npm install && npm run build",
|
||||
"build:fastapi": "rm -rf resources/fastapi && cd servers/fastapi && .venv/bin/pyinstaller --name fastapi --distpath ../../resources server.py",
|
||||
"build:electron": "tsc && node build.js",
|
||||
"clean:build": "rm -rf resources/nextjs && rm -rf resources/fastapi"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "^36.1.0",
|
||||
"electron-builder": "^26.0.12",
|
||||
"typescript": "^5.8.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
||||
// "noEmit": true, /* Disable emitting files from a compilation. */
|
||||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
||||
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
||||
"outDir": "./app_dist", /* Specify an output folder for all emitted files. */
|
||||
// "removeComments": true, /* Disable emitting comments. */
|
||||
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
||||
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue