~
在按下F5要進行偵錯的時候,預設是不會進行ts編譯的動作
每一次偵錯如果需要執行最新的ts內容都需要先Ctrl + Shift + B 進行建置
常常需要重複這樣操作會感到麻煩
[解]
透過 launch.json 設定 preLaunchTask 為 "build-typescript"
偵錯工作階段啟動前會先執行 tasks.json 底下label為 "build-typescript"的工作
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "啟動程式",
"program": "${workspaceFolder}\\bin\\www",
"preLaunchTask": "build-typescript",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}
tasks.json
{
"taskName": "tsc-watch",
"version": "2.0.0",
"tasks": [
{
// 標籤
"label": "build-typescript",
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
],
// 默認任務
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
參考 :