How to debug electron production binaries

Here’s what worked for me on Mac. In terminal type lldb path/to/build.app In the opened debugger type run –remote-debugging-port=8315. It should open a window of your app. Open Chrome at http://localhost:8315/ Click on the name of the app. For example, Webpack App. If you don’t see anything in the opened tab, focus on the window … Read more

Distinction between the renderer and main processes in Electron

The main/renderer process distinction isn’t actually an Electron concept per se — it’s inherited from Chromium (here’s an article on Chromium’s architecture and the reasoning behind it). This is the architecture that Chrome uses for performance and stability reasons. Each webContents instance runs in it’s own process (a “renderer” process). The main process (there can … Read more

Open external file with Electron

There are a couple api’s you may want to study up on and see which helps you. fs The fs module allows you to open files for reading and writing directly. var fs = require(‘fs’); fs.readFile(p, ‘utf8’, function (err, data) { if (err) return console.log(err); // data is the contents of the text file we … Read more

How to add a right-click menu in Electron that has “Inspect Element” option like Chrome?

Electron has a built-in function called win.inspectElement(x, y). Including this function as an option in a right-click context menu is possible by creating an Electron Menu with a MenuItem. Call the following in the client (aka renderer process) Javascript: // Importing this adds a right-click menu with ‘Inspect Element’ option const remote = require(‘remote’) const … Read more

Passing Data to Windows in Electron

To send events to particular window you can use webContents.send(EVENT_NAME, ARGS) (see docs). webContents is a property of a window instance: // main process storeWindow.webContents.send(‘store-data’, store); To listen for this event being sent, you need a listener in a window process (renderer): // renderer process var ipcRenderer = require(‘electron’).ipcRenderer; ipcRenderer.on(‘store-data’, function (event,store) { console.log(store); });

tech