The other day I successfully deployed the initial version of our front-end application, but encountered some confusion during the build process setup. Many Angular apps do not utilize the workspace feature unless they are creating multiple standalone applications that share code through a library. This is typically done to separate the client UI from the back-office UI.
Recently, I came across a comprehensive article on Angular library projects which provided valuable insights:
However, I found that most articles lack clarity on the overall build process aside from focusing on the library project itself. To get everything running smoothly, I had to execute specific commands (incorporating them into a script in the package.json file):
ng build my-lib-project-name && ng build &ng build my-ui-project-name --output-hashing=all --configuration=demo
Following this, I copied the contents of dist/my-ui-project-name to the server for deployment (the actual build process also occurred on the cloud server).
One curious aspect was having to perform a second ng build just before building my main project that imports the library, otherwise the main project wouldn't recognize the library components. Interestingly, this wasn't required when using ng serve and only building the library.
Furthermore, I encountered an issue with the --prod flag where one of my components couldn't be located:
ERROR in : Cannot determine the module for class SideNavMenuItemComponent in <my_path_to_project>/projects/my-lib-project-name/src/lib/layout/sidebar/side-nav-menu/side-nav-menu-item.component.ts! Add SideNavMenuItemComponent to the NgModule to fix it.
This error only appeared during the --prod build and didn't occur without the flag or during ng serve since the component had been included in an NgModule.
All these challenges made me question if my current build process is optimal. Is there anyone with experience setting up a build process for a multi-project Angular app? Especially with effective environment management strategies?
At the moment, I've added some scripts to the main package.json file and the angular.json has default build configurations. Additionally, we plan to transition from Angular 7 to Angular 8 in the near future.