reactjs - 从 vscode 调试启动时,如何使 Firefox 正确恢复其状态?
问题描述
对于我的 React webapp,我有一个启动配置来启动 Chrome 或 Firefox 进行调试。两者都工作得很好,除了 Firefox 在调试启动后没有恢复它以前的设置(或者它甚至没有保存它们)。
当我启动 Chrome 时,它会记住浏览器的大小和位置,并且我接受了本地主机的自签名证书。
Firefox 不会做任何事情。启动后,我总是必须重新定位窗口并再次接受自签名证书,随着时间的推移,这变得非常烦人。
这是我的启动设置:
{
"version": "0.2.0",
"configurations": [
{
"type": "firefox",
"request": "launch",
"reAttach": true,
"name": "Launch MSG on FF",
"url": "https://localhost:3001",
"webRoot": "${workspaceFolder}/src",
"clearConsoleOnReload": true,
"preLaunchTask": "tsc: watch"
},
{
"type": "chrome",
"request": "launch",
"name": "Launch MSG on Chrome",
"url": "https://localhost:3001",
"webRoot": "${workspaceFolder}/src",
"userDataDir": "${workspaceRoot}/.vscode/chrome",
"sourceMaps": true,
"preLaunchTask": "tsc: watch",
"sourceMapPathOverrides": {
"webpack:///build/*": "${webRoot}/*"
}
},
{
"type": "node",
"name": "Run Tests",
"request": "launch",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": [
"--config ${workspaceFolder}/jest.config.js"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true
}
]
}
在从 vscode 调试时,需要更改什么以使 FF 也保持最后状态?
以防万一这很重要:我在 macOS 上,并且调试实例的 FF 配置文件文件夹位于/var/folders/03/...
(并且该文件夹存在并且是可写的)。
解决方案
您正在寻找以下标志:
keepProfileChanges : true
此外,您可以使用以下方式指定配置文件:
profile : "dev"
而且,只需一点点,您可以使用以下命令自动打开开发工具:
firefoxArgs : [
-devtools
]
为简洁起见:
"configurations": [
{
"type": "firefox",
"request": "launch",
"reAttach": true,
"name": "Launch Name",
"clearConsoleOnReload": true,
"keepProfileChanges": true,
"profile": "dev",
"firefoxArgs": [
"-devtools",
]
]
如果您需要创建配置文件的资源:参考
Firefox CLI参考
推荐阅读
- javascript - 将卡片元素大小固定为相同的 html+Scss+javascript
- math - 什么是 (sqrt(1+8*long(num)) - 1)/2?
- swift - 'GDTCORLibrary/Public/GDTCORTransport.h' 文件未找到
- javascript - 添加标签时图表JS中的极地区域旋转
- sql - 需要基于某些条件的sql查询
- amazon-sns - 使用 AWS SNS 发送的 SMS 失败
- .net-core - 如何使用 xunit 和 moq 传递我的 DbContext 对象进行测试
- razorpay - Razorpay 直接从服务器端创建和应用付款,无需前端
- r - 如何用需要满足条件的随机值填充矩阵?
- c - shellcode中的地址在执行过程中发生变化