Reputation: 8270
So, I followed this guide on how to create an application with sub-projects. https://medium.com/disney-streaming/combining-multiple-angular-applications-into-a-single-one-e87d530d6527
I have the main-app project with sub-projects client-app, user-app, etc. The main-app contains a skeleton that loads the sub-projects as well as a shared module that each project imports.
Since these sub-projects can be built via "ng build client-app" and "ng build user-app", I was wondering would it be possible to only need to build the sub-project and not the entire main-app? I would still want to be able to build the main-app on occasion. But, if I only made changes to files in, let's say the client-app, I would only need to build just that project up the stack to production.
Upvotes: -1
Views: 944
Reputation: 349
As far as I know, you have to build the project again if a dependency changed. But luckily you can have incremental builds. At first you want to start the library build.
ng build sharedLibrary --watch
After it says finished, the window will stay open. Start a new terminal and build the sub-projects also with --watch
attached.
And at last your main-app with --watch
.
When you save a file in your sharedLibrary the build will cascade through all projects and will be faster than building from scratch.
Maybe it is too much for you, but I successfully automated that process in package.json with parallelshell and wait-on.
"build-watch": "parallelshell \"ng build shared --watch\" \"ng build Root --watch\" \"wait-on -d 2000 -w 4000 ./dist/shared/package.json && ng build ExampleProject\""
(note that Root has no dependency to shared)
To return to your Question, it is only for development. Make sure to build from ground up for production.
Upvotes: 0