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目录,再调试.真系丢累老木