Essentially VS Code allows you to create tasks to automate development processes (cleaning files/folders, compiling, bundling, etc.) and also allows you to create environment configurations to run your project.
To have them work together the environment configuration allows specification of a preLaunchTask which will run the defined task before debugging. To create a workflow similar to Visual Studio you could create a compile task and run the task before the debugger by setting it as the preLaunchTask.
Example running tsc (TypeScript compiler) before debugging
1.Create a tsconfig.json file in the root of your project with your choice of compile options.
Example tsconfig.json file (You may need to change the module setting to best suit your project. amd is typically a web project, commonjs is typically a node.js project but everyone's preference varies:
{
"compilerOptions": {
"target": "es6",
"module": "amd",
"sourceMap": true,
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules",
"bower_components",
"jspm_packages",
"tmp",
"temp"
]
}
2.Create a launch.json file to run and debug your project and set the preLaunchTask to tsc.
The easiest way to do this is simply hit F5. The first time you run it will ask to "Select an environment", if you have already created a launch.json file and would like to start fresh, delete the file. For TypeScript I normally choose node.js which will allow you to run in process or within a web context with frameworks such as express.
Example launch.json file (this example is of an express app):
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/bin/www",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": "tsc",
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"console": "internalConsole",
"sourceMaps": false,
"outDir": null
}
]
}