Skip to content

Commit

Permalink
Merge pull request #214 from pacinor/dev
Browse files Browse the repository at this point in the history
添加可调试的启动方式
  • Loading branch information
ChingCdesu authored Apr 24, 2024
2 parents 8d2f48d + 77e4bb8 commit 57c1275
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 2 deletions.
50 changes: 48 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Serve(inspector)",
"request": "launch",
"runtimeArgs": [
"scripts/serve.mjs"
],
"runtimeExecutable": "node",
"skipFiles": [
"<node_internals>/**"
],
"type": "node",
"sourceMaps": true
},

{
"type": "node",
"request": "launch",
"name": "Main(inspector)",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"runtimeArgs": [
"--remote-debugging-port=9222",
"--remote-allow-origins=*",
"${workspaceFolder}/dist/main/index.cjs",
],
"env": {
Expand All @@ -22,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",
Expand All @@ -32,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",
Expand All @@ -51,6 +81,22 @@
},
],
"compounds": [
{
"name": "main(DEBUG)",
"configurations": [
"Serve(inspector)",
"Main(inspector)",
],
"preLaunchTask": ""
},
{
"name": "Renderer(DEBUG)",
"configurations": [
"Serve(inspector)",
"Renderer(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 57c1275

Please sign in to comment.