json - VSCode 调试中的顺序启动
问题描述
鉴于对这个问题的部分回答和解决,我现在有以下启动配置来调试我的 react-redux + electron 应用程序。
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Main",
"program": "${workspaceFolder}/src/main.js",
"protocol": "inspector",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"runtimeArgs": [
"--remote-debugging-port=9229",
"."
],
"windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
}
},
{
"type": "node",
"request": "launch",
"name": "NPM",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"start"
],
"port": 9229
},
{
"type": "chrome",
"request": "launch",
"name": "Renderer",
"url": "https://localhost:3000",
"webRoot": "${workspaceFolder}/src",
"runtimeExecutable": "C:/Users/[username]/AppData/Local/Programs/Opera developer/launcher.exe",
"runtimeArgs": [
"--remote-debugging-port=9229"
],
"port": 9229
}
],
"compounds": [
{
"name": "All",
"configurations": [
"Main",
"NPM",
"Renderer"
]
}
]
}
所以它是这样工作的:NPM
配置启动 node.js 服务器,然后分别调试前端部分和后端部分Renderer
。Main
但是,当启动复合设置时,它们都会同时执行,并且https://localhost:3000/和选举应用程序都显示空白屏幕,直到服务器完全设置。
目前,一旦服务器启动就重新加载网页和电子客户端是可以的,但我只是好奇是否有办法制作顺序启动命令以使其更加优雅。有什么好主意吗?
解决方案
我认为您可以通过附加而不是启动来使您的渲染器代码更加优雅。
例如,我在启动主程序的地方使用了一个化合物,然后使用以下内容附加到渲染器(无需重新加载)。
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch",
"cwd": "${workspaceRoot}/src/app",
"runtimeExecutable": "${workspaceRoot}/src/app/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/src/app/node_modules/.bin/electron.cmd"
},
"runtimeArgs": [
"${workspaceRoot}/src/app",
"--remote-debugging-port=9222"
],
"console": "integratedTerminal",
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/src/app/out/**/*.js",
],
"protocol": "inspector",
},
{
"type": "chrome",
"request": "attach",
"name": "Attach to Renderer",
"trace": true,
"webRoot": "${workspaceRoot}/src/app",
"sourceMaps": true,
"port": 9222,
"timeout": 60000
},
],
"compounds": [
{
"name": "App Main & Renderer",
"configurations": [
"Launch App Main",
"Attach to App Renderer"
]
}
]
}
推荐阅读
- razor - 如何修复部分视图以返回结果
- css - 如何在不拉伸/裁剪 React Native 中的图像的情况下将大图像放入视图中?
- apache-nifi - NiFi UpdateRecord 不会更新嵌套字段
- javascript - 如何获取 UI-GRID 中所有页面的所有行的所有总数
- jasper-reports - 如何限制 jasper 报告不在每个组的新页面上开始?
- python - 我怎么不能得到 mysql convert tuple 错误?
- azure - 未经授权的呼叫翻译认知服务
- javascript - Selenium 测试错误 Error: socket hang up
- vb.net - 如何获取子网掩码的网络 ID?
- java - 重复的自定义对象被添加到 Hashset