vscode launch.json和 tasks.json内部变量,ts debug问题

https://code.visualstudio.com/docs/editor/variables-reference

The following predefined variables are supported:

  • ${userHome} - the path of the user's home folder
  • ${workspaceFolder} - the path of the folder opened in VS Code
  • ${workspaceFolderBasename} - the name of the folder opened in VS Code without any slashes (/)
  • ${file} - the current opened file
  • ${fileWorkspaceFolder} - the current opened file's workspace folder
  • ${relativeFile} - the current opened file relative to workspaceFolder
  • ${relativeFileDirname} - the current opened file's dirname relative to workspaceFolder
  • ${fileBasename} - the current opened file's basename
  • ${fileBasenameNoExtension} - the current opened file's basename with no file extension
  • ${fileExtname} - the current opened file's extension
  • ${fileDirname} - the current opened file's folder path
  • ${fileDirnameBasename} - the current opened file's folder name
  • ${cwd} - the task runner's current working directory upon the startup of VS Code
  • ${lineNumber} - the current selected line number in the active file
  • ${selectedText} - the current selected text in the active file
  • ${execPath} - the path to the running VS Code executable
  • ${defaultBuildTask} - the name of the default build task
  • ${pathSeparator} - the character used by the operating system to separate components in file paths
  • ${/} - shorthand for ${pathSeparator}

${workspaceRoot} 已经不用了? 改用${workspaceFolder}?

ts 在vscode下debug.

1. tsconfig.json 问题配置sourceMap选项, chrome和node能根据编译出的js 和map 文件,对应到原来ts文件.

{

    "compilerOptions": {

        "target": "es6",

        "module": "es6",

        "outDir": "../../bin/tsc/layaAir",

....

        "sourceMap":true,

 .....

    }

}

2. .vscode/lauch.json的配置, 并且添加sourceMapPathOverrides 路径映射, 打开编译出的map file,

看到路径开关是什么,以它作为key, 工程中ts路径为value

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
			"name": "chrome调试",
			"type": "chrome",
			"request": "launch",
            "url":"http://127.0.0.1:8002",
		
			"runtimeArgs": [
				"--allow-file-access-from-files",
				"--disable-web-security"	// 跨域支持
			],
			"sourceMaps": true,
			"webRoot": "${workspaceFolder}",
			"userDataDir": "${workspaceFolder}/.vscode/chrome",
			"sourceMapPathOverrides": {
				//"../src0/*": "${workspaceRoot}/Loading/src0/*",
                "../../../../../../../src/layaAir/*": "${workspaceFolder}/src/layaAir/*",
                "../../../src/samples/*": "${workspaceFolder}/src/samples/*",
			}
		},

3. 缓存问题, userDataDir会缓存js代码,有时发现编译后代码还是旧的,可以删除.vscode/chrome目录,再调试.真系丢累老木

相关推荐

  1. 变量函数提升(js的问题

    2024-07-20 05:44:05       55 阅读
  2. 变量函数提升(js的问题

    2024-07-20 05:44:05       32 阅读
  3. react函数式组件每次setstate内部变量重新赋值问题

    2024-07-20 05:44:05       25 阅读
  4. Vim 粘贴内容时全变成注释的问题

    2024-07-20 05:44:05       46 阅读
  5. golang变量常见问题总结

    2024-07-20 05:44:05       29 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-20 05:44:05       52 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-20 05:44:05       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-20 05:44:05       45 阅读
  4. Python语言-面向对象

    2024-07-20 05:44:05       55 阅读

热门阅读

  1. 目标检测详解

    2024-07-20 05:44:05       18 阅读
  2. jvm介绍

    jvm介绍

    2024-07-20 05:44:05      19 阅读
  3. @SpringBootApplication 注解及源码 详解

    2024-07-20 05:44:05       19 阅读
  4. HRCSA作业

    2024-07-20 05:44:05       15 阅读
  5. VB6打印技术-VB6单位缇转毫米,毫米转缇

    2024-07-20 05:44:05       13 阅读
  6. mysql的备份和恢复和日志管理

    2024-07-20 05:44:05       14 阅读
  7. 形状之美:WebKit中CSS形状的实现与创新

    2024-07-20 05:44:05       18 阅读
  8. 掌控视界:WebKit与CSS视口单位的卓越支持

    2024-07-20 05:44:05       16 阅读