Skip to content

Instantly share code, notes, and snippets.

@sfengyuan
Last active September 18, 2021 15:30
Show Gist options
  • Save sfengyuan/696c8234ac97d99f4b1c2ecfd3252e9d to your computer and use it in GitHub Desktop.
Save sfengyuan/696c8234ac97d99f4b1c2ecfd3252e9d to your computer and use it in GitHub Desktop.
Install chrome extension devtools to Electron projects
import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer';
...
app.on('ready', () => {
const mainWindow = createWindow()
if (process.env.mode === 'development') {
installExtension(VUEJS_DEVTOOLS)
.then((name) => console.log('installed ', name))
.catch((err) => console.log('An error occurred: ', err));
const ses = mainWindow.webContents.session
console.log('renderer storage path: ', ses.getStoragePath())
mainWindow.webContents.on('did-frame-finish-load', () => {
mainWindow.webContents.once('devtools-opened', () => {
mainWindow.focus()
})
mainWindow.webContents.openDevTools()
})
}
})
// in the renderer storage path, open the extension manifest.json, delete all the unrecognized fields.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment