Instantly share code, notes, and snippets.

Embed
What would you like to do?
TypeScript向けBuild/Watchタスクの定義 (VSCode用 tasks.json )

tasks.json

build

  • -p .でカレントディレクトリ内のtsconfig.jsonを参照し、その情報を元にコンパイル
    • "args": ["file1.ts","file2.ts"] のように指定することで、指定されたファイルのみをコンパイル

watch

  • -wでファイルを監視
  • VSCodeなら[Tasks: Terminate Runnning Tasks]で終了できます

tsconfig.json

{
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"windows": {
"command": "tsc.exe"
},
"tasks": [
{
"taskName": "build",
"isBuildCommand": true,
"suppressTaskName": true,
"args": ["-p","."],
"problemMatcher": "$tsc"
},
{
"taskName": "watch",
"isBuildCommand": false,
"isWatching": true,
"suppressTaskName": true,
"args": ["-w"],
"problemMatcher": "$tsc"
}
]
}
{
"compilerOptions": {
"target": "ES3",
"module": "commonjs",
"sourceMap": true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment