Search code examples
angularangular-cliangular-cli-v6

Run two Angular CLI tasks after each other, with --watch


I have two tasks, that need to run after each other:

ng build <library-name> && ng serve

I want to have file change watching on the <libary-name>, so I add this:

ng build <library-name> --watch && ng serve

This is obviously not working, as the watch will never finish, so the ng serve will never get called.

ng build <library-name> --watch & ng serve

this solution is also not good, as the ng serve starts before the ng build finishes.

Is there any way, to capture the Compilation complete message from the first ng build, and then let file watcher run? Is there any way to just start the watcher maybe like this:

ng build <library-name> && --watch-the-libary-please & ng serve

?


Solution

  • You can use npm package concurrently, which allows running multiple commands in parallel.