Skip to content

Commit

Permalink
[Tech] Make it possible to disable the React developer tools (#1895)
Browse files Browse the repository at this point in the history
* Make it possible to disable the React dev tools

* Add note about the new variable to README
  • Loading branch information
CommandMC committed Oct 14, 2022
1 parent b297456 commit a8bca14
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ To do that, open up the command palette (Ctrl + P), type in "task" and press Spa
If you want to quickly test a change, or you're implementing features that require a lot of restarts, you can use Vite's development server to speed up the process:
Go to the "Run and Debug" tab of VSCode and start the "Launch Heroic (HMR & HR)" task (alternatively, if you're not using VSCode or just prefer the terminal, run `yarn dev`). Heroic will start up after a short while, and once you make any change to the code, it'll reload/restart.

Note: If you do not need the React developer tools while testing changes, you can skip their install by setting the `HEROIC_NO_REACT_DEVTOOLS` environment variable before running `yarn dev` (for example with `HEROIC_NO_REACT_DEVTOOLS=1 yarn dev`).

### Development Using a Container

<details>
Expand Down
18 changes: 10 additions & 8 deletions src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,17 @@ async function createWindow(): Promise<BrowserWindow> {
}

if (!app.isPackaged) {
/* eslint-disable @typescript-eslint/ban-ts-comment */
//@ts-ignore
import('electron-devtools-installer').then((devtools) => {
const { default: installExtension, REACT_DEVELOPER_TOOLS } = devtools
if (!process.env.HEROIC_NO_REACT_DEVTOOLS) {
import('electron-devtools-installer').then((devtools) => {
const { default: installExtension, REACT_DEVELOPER_TOOLS } = devtools

installExtension(REACT_DEVELOPER_TOOLS).catch((err: string) => {
logWarning(['An error occurred: ', err], { prefix: LogPrefix.Backend })
installExtension(REACT_DEVELOPER_TOOLS).catch((err: string) => {
logWarning(['An error occurred: ', err], {
prefix: LogPrefix.Backend
})
})
})
})
}
mainWindow.loadURL('http://localhost:5173')
// Open the DevTools.
mainWindow.webContents.openDevTools()
Expand Down Expand Up @@ -779,7 +781,7 @@ ipcMain.handle(
}

try {
// @ts-ignore This is actually fine as long as the frontend always passes the right InstallPlatform for the right runner
// @ts-expect-error This is actually fine as long as the frontend always passes the right InstallPlatform for the right runner
const info = await getGame(game, runner).getInstallInfo(installPlatform)
return info
} catch (error) {
Expand Down

0 comments on commit a8bca14

Please sign in to comment.