-1

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.

ScubaSteve
  • 7,724
  • 8
  • 52
  • 65
  • 1
    ... `ng add @nrwl/workspace` ... – Vovan_Super Nov 03 '21 at 19:11
  • hey, I didn't down-voted your question ... and sure it's possible to build particularly you lib / separate app (in you `angular.json` - definitions for every - so you build `ng b app/lib:name` .. but really, `Nx` brings lots of additional sugar ..) – Vovan_Super Nov 04 '21 at 05:59
  • So, I have both lazy-loaded modules and sub projects that act like lazy-loaded modules. I just want to be able to build either the modules or sub projects so that it creates the 9.0a9be675------------.js file so that I can push just that file up the stack to production and the next time that module is needed, it loads the newer version of the file. – ScubaSteve Nov 04 '21 at 13:04

1 Answers1

0

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.

b2f
  • 196
  • 2
  • 10
  • My question is really about building for production. I am looking to only build the sub-project that was changed to production without needing to build the entire main-app. – ScubaSteve Nov 03 '21 at 19:29