From 139b2edcb10792b7d3ef1617571cd119791b9750 Mon Sep 17 00:00:00 2001 From: "yutian.yz" Date: Fri, 20 May 2022 14:29:47 +0800 Subject: [PATCH] feat: support react developer tools --- package.json | 1 + src/main/launch.ts | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/package.json b/package.json index d389c20b..d14286fc 100644 --- a/package.json +++ b/package.json @@ -108,6 +108,7 @@ "css-loader": "^2.1.1", "electron": "18.0.3", "electron-builder": "^23.0.3", + "electron-devtools-installer": "^3.2.0", "electron-rebuild": "^3.2.7", "eslint": "^8.11.0", "eslint-config-prettier": "^8.5.0", diff --git a/src/main/launch.ts b/src/main/launch.ts index bae75273..9f0cd0e1 100644 --- a/src/main/launch.ts +++ b/src/main/launch.ts @@ -6,6 +6,7 @@ import { isOSX, URI } from '@opensumi/ide-core-common'; import { MainModule } from './services'; import { OpenSumiDesktopMainModule } from './module'; import { WebviewElectronMainModule } from '@opensumi/ide-webview/lib/electron-main'; +import installExtension, { REACT_DEVELOPER_TOOLS } from 'electron-devtools-installer'; const getResourcesPath = () => { const appPath = app.getAppPath(); @@ -42,6 +43,14 @@ export async function launch(workspace?: string) { await Promise.all([electronApp.init(), app.whenReady(), ensureDir(getExtensionDir())]); + await installExtension(REACT_DEVELOPER_TOOLS, { + loadExtensionOptions: { allowFileAccess: true }, + forceDownload: true, + }) + .then((name) => console.log(`Added Extension: ${name}`)) + .then(() => {}) + .catch((err) => console.error('An error occurred: ', err)); + if (!workspace || !existsSync(workspace)) { if (electronApp.getCodeWindows().length === 0) { electronApp.loadWorkspace(undefined, undefined);