forked from trent_larson/crowd-funder-for-time-pwa
feat(electron): improve electron build configuration
- Add dedicated electron build scripts for each platform - Configure Vite rollup options for electron builds - Update electron-builder configuration with proper app metadata - Add clean script and rimraf dependency - Set proper appId and build settings for production builds - Enable asar packaging for better security
This commit is contained in:
@@ -1,46 +1,44 @@
|
||||
const { app, BrowserWindow } = require("electron");
|
||||
const path = require("path");
|
||||
|
||||
let mainWindow;
|
||||
|
||||
app.on("ready", () => {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
function createWindow() {
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 1200,
|
||||
height: 800,
|
||||
webPreferences: {
|
||||
//preload: path.join(__dirname, "preload.js"),
|
||||
contextIsolation: true, // Security setting
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
},
|
||||
});
|
||||
|
||||
const indexPath = path.join(
|
||||
__dirname,
|
||||
"../../",
|
||||
"dist-electron",
|
||||
"index.html",
|
||||
);
|
||||
|
||||
console.log("Loading Vue app from:", indexPath);
|
||||
mainWindow.webContents.openDevTools();
|
||||
|
||||
mainWindow.webContents.on(
|
||||
"did-fail-load",
|
||||
(event, errorCode, errorDescription, validatedURL) => {
|
||||
console.error(
|
||||
"Failed to load:",
|
||||
validatedURL,
|
||||
"Error:",
|
||||
errorDescription,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
mainWindow.webContents.on("console-message", (event, level, message) => {
|
||||
console.log(`[Renderer] ${message}`);
|
||||
});
|
||||
// Log the paths we're trying to load from
|
||||
const appPath = app.getAppPath();
|
||||
const indexPath = path.join(appPath, "www", "index.html");
|
||||
console.log("App path:", appPath);
|
||||
console.log("Trying to load from:", indexPath);
|
||||
|
||||
// Load the index.html file
|
||||
mainWindow.loadFile(indexPath).catch((err) => {
|
||||
console.error("Failed to load index.html:", err);
|
||||
// Try to list directory contents to debug
|
||||
const fs = require("fs");
|
||||
console.log("Directory contents:", fs.readdirSync(appPath));
|
||||
});
|
||||
|
||||
// Open the DevTools in development
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
mainWindow.webContents.openDevTools();
|
||||
}
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
|
||||
app.on("activate", () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -49,3 +47,8 @@ app.on("window-all-closed", () => {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
// Handle any errors
|
||||
process.on("uncaughtException", (error) => {
|
||||
console.error("Uncaught Exception:", error);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user