Skip to content

Instantly share code, notes, and snippets.

@bonprosoft
Last active October 9, 2017 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bonprosoft/fd414f1c7d6f12bd1d6f to your computer and use it in GitHub Desktop.
Save bonprosoft/fd414f1c7d6f12bd1d6f to your computer and use it in GitHub Desktop.
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