From 94739ce534c7310c90356059a4bd3868b468d20a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Gediz=20Ayd=C4=B1ndo=C4=9Fmu=C5=9F?= Date: Wed, 15 Feb 2023 00:03:52 +0300 Subject: [PATCH] Update main.js Refer to preload.js And some changes on whenReady for easier debugging --- main.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 58903f1..ce72f1f 100644 --- a/main.js +++ b/main.js @@ -1,11 +1,15 @@ // Importing modules const { app, BrowserWindow } = require('electron') +const path = require('path') // Reusable function to instantiate windows const createWindow = () => { const win = new BrowserWindow({ width: 800, height: 600, + webPreferences: { + preload: path.join(__dirname, 'preload.js'), + } }) win.loadFile('index.html') @@ -17,7 +21,9 @@ app.whenReady().then(() => { // Open a window if none are open (macos only) app.on('activate', () => { - if (BrowserWindow.getAllWindows().length === 0) createWindow() + if (BrowserWindow.getAllWindows().length === 0) { + createWindow() + } }) })