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)