Skip to content

Commit

Permalink
添加可调试的启动方式
Browse files Browse the repository at this point in the history
  • Loading branch information
pacinor committed Apr 9, 2024
1 parent 8d2f48d commit 3fa2a2c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Serve(inspector)",
"request": "launch",
"runtimeArgs": [
"scripts/serve.mjs"
],
"runtimeExecutable": "node",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},

{
"type": "node",
"request": "launch",
Expand Down Expand Up @@ -51,6 +64,14 @@
},
],
"compounds": [
{
"name": "DEBUG",
"configurations": [
"Serve(inspector)",
"Main(inspector)",
],
"preLaunchTask": ""
},
{
"name": "All(inspector)",
"configurations": [
Expand Down
30 changes: 30 additions & 0 deletions scripts/serve.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { build, createServer } from 'vite'

/**
* @type {(server: import('vite').ViteDevServer) => Promise<import('rollup').RollupWatcher>}
*/
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)

0 comments on commit 3fa2a2c

Please sign in to comment.