Reputation: 23
I need to build 2 applications (New1 and New2) with watch option, so any files changes in any of those 2 apps lead to re-build.
ng build New1 && ng build New2
works fine, I can see both apps built under /dist directory,
but I cannot get ng build --watch
to work the same way. So far I tried:
1) ng build New1 && ng build New2 --watch
Builds both apps, but then only watches New2.
If I make changes to New1, the build doesn't happen again.
2) ng build New1 --watch && ng build New2 --watch
Only builds New1 app and watches it.
3) ng build New1 --output-path dist/New1 && ng build New2 --output-path dist/New2 --watch
Builds both apps, but then only watches New2.
4) ng build New1 --output-path dist/New1 --watch && ng build New2 --output-path dist/New2 --watch
Only builds New1 app and watches it.
Is there a way to use build --watch for 2 apps in one line at all?
Appreciate the suggestions.
Angular CLI: 6.2.4
Node: 10.11.0
OS: win32 x64
Angular:
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.8.4
@angular-devkit/core 0.8.4
@angular-devkit/schematics 0.8.4
@schematics/angular 0.8.4
@schematics/update 0.8.4
rxjs 6.2.2
typescript 2.9.2
Upvotes: 2
Views: 1740
Reputation: 2601
If you're trying to run 2 calls at the same time, I'd suggest the concurrently
package:
https://www.npmjs.com/package/concurrently
It's pretty easy to combine calls. You would add a new script to package.json and combine 2 commands. Below has not been tested with your code so please read the docs:
"build:concurrent": "concurrently \"ng build New1 --watch\" \"ng build New2 --watch\"",
You would then run it in the terminal using npm run build:concurrent
Upvotes: 1
Reputation: 8605
The reason ng build New1 --watch && ng build New2 --watch
doesn't work, is because the first build needs to finish before the second starts.
My solution? Just open two terminals and run one build --watch
in each. If you're using VS Code's built-in terminal, they will be in two different tabs, but will work together.
Edit: Plan B
Assuming you're on Windows, the start
command opens a new terminal and returns.
So you could use this, and it should work just fine:
start ng build New1 --watch && start ng build New2 --watch
Upvotes: 1