Electron supports the Chrome DevTools Extension, which can be used to extend the ability of devtools for debugging popular web frameworks.
This document outlines the process for manually loading an extension. You may also try electron-devtools-installer, a third-party tool that downloads extensions directly from the Chrome WebStore.
To load an extension in Electron, you need to download it in Chrome browser, locate its filesystem path, and then load it by calling the BrowserWindow.addDevToolsExtension(extension)
API.
Using the React Developer Tools as example:
Install it in Chrome browser.
Navigate to chrome://extensions
, and find its extension ID, which is a hash string like fmkadmapgofadopljbjfkapdkoienihi
.
Find out filesystem location used by Chrome for storing extensions:
%LOCALAPPDATA%\Google\Chrome\User Data\Default\Extensions
;~/.config/google-chrome/Default/Extensions/
~/.config/google-chrome-beta/Default/Extensions/
~/.config/google-chrome-canary/Default/Extensions/
~/.config/chromium/Default/Extensions/
~/Library/Application Support/Google/Chrome/Default/Extensions
.Pass the location of the extension to BrowserWindow.addDevToolsExtension
API, for the React Developer Tools, it is something like:
const path = require('path') const os = require('os') BrowserWindow.addDevToolsExtension( path.join(os.homedir(), '/Library/Application Support/Google/Chrome/Default/Extensions/fmkadmapgofadopljbjfkapdkoienihi/4.3.0_0') )
Note: The BrowserWindow.addDevToolsExtension
API cannot be called before the ready event of the app module is emitted.
The extension will be remembered so you only need to call this API once per extension. If you try to add an extension that has already been loaded, this method will not return and instead log a warning to the console.
You can pass the name of the extension to the BrowserWindow.removeDevToolsExtension
API to remove it. The name of the extension is returned by BrowserWindow.addDevToolsExtension
and you can get the names of all installed DevTools Extensions using the BrowserWindow.getDevToolsExtensions
API.
Electron only supports a limited set of chrome.*
APIs, so some extensions using unsupported chrome.*
APIs for chrome extension features may not work. Following Devtools Extensions are tested and guaranteed to work in Electron:
First please make sure the extension is still being maintained, some extensions can not even work for recent versions of Chrome browser, and we are not able to do anything for them.
Then file a bug at Electron's issues list, and describe which part of the extension is not working as expected.
© GitHub Inc.
Licensed under the MIT license.
https://www.electronjs.org/docs/tutorial/devtools-extension