Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
feat: auto disable devtool in vscode debug
Browse files Browse the repository at this point in the history
  • Loading branch information
neko-para committed Nov 1, 2023
1 parent 9ffc23e commit 41778cf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "node",
"request": "launch",
"name": "Electron: Main",
"runtimeArgs": ["scripts/watch.mjs"]
"runtimeArgs": ["scripts/watch.mjs", "--nodevtool"]
},
{
"name": "Electron: Renderer",
Expand Down
6 changes: 5 additions & 1 deletion app/main/src/misc/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ function useDebug(window: BrowserWindow): void {
// console.error(`An error occurred while install extension: ${err.message}`)
// )

// window.webContents.openDevTools({ mode: 'detach' })
if ('MAAY_NO_DEVTOOL' in process.env) {
console.log('disabled devtools')
} else {
window.webContents.openDevTools({ mode: 'detach' })
}

// Bypass CORS
const bypass_urls = [
Expand Down
5 changes: 5 additions & 0 deletions scripts/watch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ async function watchMain(server) {
VITE_DEV_SERVER_HOST: address.address,
VITE_DEV_SERVER_PORT: address.port
})
if (process.argv.includes('--nodevtool')) {
Object.assign(env, {
MAAY_NO_DEVTOOL: '1'
})
}
const ctx = await esbuild.context({
entryPoints: ['app/main/src/main.ts'],
platform: 'node',
Expand Down

0 comments on commit 41778cf

Please sign in to comment.