Skip to content

How to open dev tools in separate window? #1007

Answered by hyperknot
hyperknot asked this question in Q&A
Discussion options

You must be logged in to vote

I solved it, here is how to make an undocked devtools which is snapping to the right side of the main window.

import { BrowserWindow } from 'electron'

const WIDTH = 600
const HEIGHT = 800
export function openDevTools(mainWindow) {
  if (!mainWindow) return

  const devtools = new BrowserWindow({ show: false })
  mainWindow.webContents.setDevToolsWebContents(devtools.webContents)
  mainWindow.webContents.openDevTools({ mode: 'undocked' })

  mainWindow.webContents.on('did-stop-loading', () => {
    fixSize(mainWindow, devtools)
  })
  mainWindow.on('move', () => {
    fixSize(mainWindow, devtools)
  })
}

function fixSize(mainWindow, devtools) {
  const windowBounds = mainWindow.getBounds()

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hyperknot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant