如何使用 VSCode 在 Firefox 中保留扩展并请求启动

Die*_*sel 2 firefox reactjs visual-studio-code react-devtools

我正在尝试使用 React Dev Tools 和 Firefox Developer Edition 调试 React 应用程序。我无法将 React Dev Tools 安装到 Firefox 通过 VSCode 启动时使用的配置文件。当我通过在 /Applications 中打开它自己启动 Firefox 时,我已经安装了 React Dev Tools。

但是,当我运行以下launch.json配置文件时,在 FireFox 启动后,首选项 -> 扩展和主题 -> 扩展下没有显示任何扩展。

{
  "name": "Launch localhost",
  "type": "firefox",
  "request": "launch",
  "reAttach": true,
  "url": "http://localhost:3000",
  "webRoot": "${workspaceFolder}"
},
Run Code Online (Sandbox Code Playgroud)

但是,我可以按照此处的说明使用终端启动 Firefox 并将我的调试器附加到它。此配置文件具有 React Dev Tools,并且可以正常运行:

/Applications/Firefox\ Developer\ Edition.app/Contents/MacOS/firefox -start-debugger-server
Run Code Online (Sandbox Code Playgroud)

启动.json:

{
  "name": "Attach",
  "type": "firefox",
  "request": "attach",
  "url": "http://localhost:3000",
  "webRoot": "${workspaceFolder}"
},
Run Code Online (Sandbox Code Playgroud)

但是如何使第一个与launch请求一起工作而不是attach?从阅读来看似乎与个人资料有关

Jon*_*auw 5

我遇到了同样的问题,并且能够通过添加到我的 launch.json 来修复它:

"profile": "my-firefox-profile"
Run Code Online (Sandbox Code Playgroud)

Firefox 可以安装多个配置文件。您可以通过about:profiles在 firefoxes 地址栏中键入来检查它们。它将向您显示配置文件列表。标记为的Default profile: yes那个应该是要选择的那个。

在此处输入图片说明

我的 launch.json 现在看起来像这样:

    {
        "name": "Firefox",
        "type": "firefox",
        "request": "launch",
        "reAttach": true,
        "url": "http://localhost:4300",
        "webRoot": "${workspaceFolder}",
        "profile": "default-release-1"
    },
Run Code Online (Sandbox Code Playgroud)

背景:

Firefox 配置文件包含浏览历史记录、书签等设置 - 最重要的是 - 附加组件。通过告诉 VSCode 使用它与已安装插件一起提供的特定配置文件。

如果您在使用 Angular 或 Vue 时遇到同样的问题,这也将起作用。