From 3fa2a2c9ed72b5013b0942b65d67452f1e8fb3ca Mon Sep 17 00:00:00 2001 From: pacinor <2177271479@qq.com> Date: Tue, 9 Apr 2024 21:12:21 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=AF=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E7=9A=84=E5=90=AF=E5=8A=A8=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 21 +++++++++++++++++++++ scripts/serve.mjs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 scripts/serve.mjs diff --git a/.vscode/launch.json b/.vscode/launch.json index b81c9476..6e5c6003 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,6 +1,19 @@ { "version": "0.2.0", "configurations": [ + { + "name": "Serve(inspector)", + "request": "launch", + "runtimeArgs": [ + "scripts/serve.mjs" + ], + "runtimeExecutable": "node", + "skipFiles": [ + "/**" + ], + "type": "node" + }, + { "type": "node", "request": "launch", @@ -51,6 +64,14 @@ }, ], "compounds": [ + { + "name": "DEBUG", + "configurations": [ + "Serve(inspector)", + "Main(inspector)", + ], + "preLaunchTask": "" + }, { "name": "All(inspector)", "configurations": [ diff --git a/scripts/serve.mjs b/scripts/serve.mjs new file mode 100644 index 00000000..675cad69 --- /dev/null +++ b/scripts/serve.mjs @@ -0,0 +1,30 @@ +import { build, createServer } from 'vite' + +/** + * @type {(server: import('vite').ViteDevServer) => Promise} + */ +function watchPreload(server) { + return build({ + configFile: 'packages/preload/vite.config.ts', + mode: 'development', + plugins: [ + { + name: 'electron-preload-watcher', + writeBundle() { + server.ws.send({ type: 'full-reload' }) + }, + }, + ], + build: { + watch: true, + }, + }) +} + +// bootstrap +const server = await createServer({ + configFile: 'packages/renderer/vite.config.ts', +}) + +await server.listen() +await watchPreload(server) From b9537628ec186627ce39ab2a0408a81e38d43561 Mon Sep 17 00:00:00 2001 From: pacinor <2177271479@qq.com> Date: Wed, 10 Apr 2024 13:23:56 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E5=87=BA=E7=8E=B0=E2=80=9CDebugging=20connec?= =?UTF-8?q?tion=20was=20closed.Reason:WebSocket=20disconnectedReconnectwhe?= =?UTF-8?q?n=20readybyreopeningDevTools.=E2=80=9D=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=AF=B9Renderer=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E8=B0=83=E8=AF=95=E7=9A=84=E6=96=B9=E5=BC=8FRenderer(?= =?UTF-8?q?DEBUG)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 6e5c6003..686def73 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,7 +11,8 @@ "skipFiles": [ "/**" ], - "type": "node" + "type": "node", + "sourceMaps": true }, { @@ -21,6 +22,7 @@ "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", "runtimeArgs": [ "--remote-debugging-port=9222", + "--remote-allow-origins=*", "${workspaceFolder}/dist/main/index.cjs", ], "env": { @@ -35,8 +37,21 @@ "type": "chrome", "request": "launch", "name": "Renderer(inspector)", - "url": "http://localhost:9222", - "webRoot": "${workspaceFolder}/dist/packages/renderer", + "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", + "runtimeArgs": [ + "--remote-debugging-port=9222", + "--remote-allow-origins=*", + "${workspaceFolder}/dist/main/index.cjs", + ], + "env": { + "DEBUG": "true", + }, + "windows": { + "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd" + }, + "sourceMaps": true, + "url": "http://localhost:3344", + "webRoot": "${workspaceFolder}/packages/renderer", }, { "type": "node", @@ -45,6 +60,8 @@ "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", "runtimeArgs": [ "${workspaceFolder}/dist/main/index.cjs", + "--remote-debugging-port=9222", + "--remote-allow-origins=*", ], "env": { "VITE_DEV_SERVER_HOST": "127.0.0.1", @@ -65,7 +82,15 @@ ], "compounds": [ { - "name": "DEBUG", + "name": "main(DEBUG)", + "configurations": [ + "Serve(inspector)", + "Main(inspector)", + ], + "preLaunchTask": "" + }, + { + "name": "Renderer(DEBUG)", "configurations": [ "Serve(inspector)", "Main(inspector)", From 77e4bb8df339668d89f8ef74d869bc0f43c1946b Mon Sep 17 00:00:00 2001 From: pacinor <2177271479@qq.com> Date: Wed, 10 Apr 2024 13:49:09 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9Renderer(DEBUG)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 686def73..01da29cf 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -93,7 +93,7 @@ "name": "Renderer(DEBUG)", "configurations": [ "Serve(inspector)", - "Main(inspector)", + "Renderer(inspector)", ], "preLaunchTask": "" },