美文网首页
vscode debug(vue/react配置)

vscode debug(vue/react配置)

作者: 马建阳 | 来源:发表于2019-03-11 21:27 被阅读0次

之前调试代码经常是chorme设断点和console.log调试,感觉过于麻烦。后来用react的时候就在vscode调试感觉特别爽,于是整理了vscode的debugger配置(备忘)。attach模式需要设置chrome端口,而vue需要配置webpack以防止断点不匹配。

react

{
  // 使用 IntelliSense 了解相关属性。 
  // 悬停以查看现有属性的描述。
  // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "attach",
      "name": "Attach to Chrome",
      "port": 9222,
      "url": "http://localhost:3001/#/login",
      "webRoot": "${workspaceFolder}"
    },
    {
      "type": "chrome",
      "request": "launch",
      "name": "Launch Chrome against localhost",
      "url": "http://localhost:3001",
      "webRoot": "${workspaceFolder}"
    }
  ]
}

vue

attach模式配置
简单讲:

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "attach",
      "name": "Attach to Chrome",
      "port": 9222,
      "webRoot": "${workspaceRoot}/src",
      "url": "http://localhost:8080/#/",
      "sourceMaps": true,
      "sourceMapPathOverrides": {
        "webpack:///src/*": "${webRoot}/*"
      }
    }
  ]
}
config/index.js下dev节点下修改:
devtool: 'eval-source-map',
cacheBusting: false,

launch模式配置

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "vuejs: chrome",
      "url": "http://localhost:8080",
      "webRoot": "${workspaceFolder}/src",
      "breakOnLoad": true,
      "sourceMapPathOverrides": {
        "webpack:///src/*": "${webRoot}/*"
      }
    },
    {
      "type": "firefox",
      "request": "launch",
      "name": "vuejs: firefox",
      "url": "http://localhost:8080",
      "webRoot": "${workspaceFolder}/src",
      "pathMappings": [{ "url": "webpack:///src/", "path": "${webRoot}/" }]
    }
  ]
}
请设置并更新 config/index.js 内的 devtool 属性:

devtool: 'source-map',

相关文章

  • vscode debug(vue/react配置)

    之前调试代码经常是chorme设断点和console.log调试,感觉过于麻烦。后来用react的时候就在vsco...

  • vscode配置PHP Debug

    感谢作者,此篇文章非我写。 vscode配置PHP Debug 1、先在vscode中安装PHP Debug,在设...

  • VSCode调试Ember配置

    安装 vscode-chrome-debug 进行插件配置(配置如下) launch.json

  • Mac VSCode CMAKE C++ 代码调试

    [TOC] 安装VSCode插件(C/C++、codelldb) 配置CMakeLists.txt(debug配置...

  • vscode c++ debug

    问题:mac机器上使用vscode debug c++,按照网上文章配置后,启动debug会报错: debug提示...

  • VsCode Task/Launch配置文件

    部分配置参数 首先在Debug/Run中创建一个.vscode文件. Windows下VsCode单文件调试配置 ...

  • RN项目VsCode调试

    RN项目使用VsCode调试 安装插件React Native Tools 点击Debug->Add Config...

  • vs code

    2018 vscode 前端最佳配置 emmet in vue

  • 调试 vite+vue+ts

    调试 debug vite+vue+ts 以调试 vue3-demos 为例: vscode 调试 添加以下文件....

  • React基础

    一、创建React项目 $ npx create-react-app myreact 二、vscode配置jsx ...

网友评论

      本文标题:vscode debug(vue/react配置)

      本文链接:https://www.haomeiwen.com/subject/unfqpqtx.html