How to view multiple TypeScript projects in VSCode?

I have 10 TypeScript project folders next to each other, each of which contains tsconfig.json in its root. For various reasons, projects should be compiled separately. To automatically create this project when the source code changes, I run the following from the Windows batch file for each project:

 tsc -w 

From the batch file, this is done using start , so different tsc can be executed in parallel:

 start tsc -w -p ./Project1 start tsc -w -p ./Project2 ... 

Now the problem is that this, depending on additional parameters, also:

  • creates 10 command line windows, so the clock may be closed later
  • runs invisibly, in which case the clock can only be killed from the task manager

... none of them are desirable. So, what would be the โ€œrightโ€ way to view multiple TypeScript projects in Visual Studio code?


Edit

I was wrong in this part:

runs invisibly, in which case the clock can only be killed from the task manager

If the task is started using

 start /B tsc -w -p ./Project1 

... then closing the command line with which it was run will also close the โ€œinvisibleโ€ task, at least in Windows 10. I checked this from the Task Manager.

+5
source share
2 answers

The most elegant solution I've found is to use concurrently package

Install

 npm i -g concurrently 

Using

 concurrently "tsc -w -p ./Project1" "tsc -w -p ./Project2" 
0
source

You can do this using the task file, but be sure to use "version": "2.0.0" , as this does not work with older versions. Once you .vscode/tasks.json this .vscode/tasks.json , put it in it and modify it to suit your needs. Once you are ready to start the task, just run the main Build task, and it should start your other tsc tasks.

 { "version": "2.0.0", "command": "tsc", "problemMatcher":"$tsc-watch", "showOutput": "always", "echoCommand": true, "tasks": [ { "taskName": "Build", "isBuildCommand": true, "dependsOn": [ "Build A", "Build B", "Build C" ] }, { "taskName": "Build A", "args": [ "-w", "-p", "./src/project-a" ] }, { "taskName": "Build B", "args": [ "-w", "-p", "./src/project-b" ] }, { "taskName": "Build C", "args": [ "-w", "-p", "./src/project-c" ] } ] } 
0
source

Source: https://habr.com/ru/post/1265111/


All Articles