Fabio Marzocca
Fabio Marzocca

Reputation: 1677

Chrome Dev tools in electron app?

I have found that, while running some Electron app, I can access Chrome Dev Tools by pressing Cmd-Alt-I, while on some others I can't. I am wondering which is the setting to avoid/enable this behaviour.

Upvotes: 5

Views: 8108

Answers (1)

mr.freeze
mr.freeze

Reputation: 14062

There are a couple of options. You can initialize your BrowserWindow without devtools:

mainWindow = new BrowserWindow({
  width: 800,
  height: 600,
  webPreferences: {
    devTools: false
  }
});

Or you can catch the opened event on the webContents and close it:

mainWindow.webContents.on("devtools-opened", () => {
   mainWindow.webContents.closeDevTools();
});

Upvotes: 6

Related Questions