This is a demo project for Spring Boot with Module Federation and Angular. The point of this project is to host an Angular app with multiple micro frontend (mfe) apps, that all run within the same Spring Boot context. No mfe should be hosted separately.
The project hosts a single Spring Boot application.
The /application
folder contains the Angular application.
The /library
folder contains a micro frontend application.
The /core
folder contains a shared library, both Java and Angular
When both application are built, the Spring Boot application will serve the Angular application and the micro frontend application.
The easy way to install core library is having a local verdaccio
server :
npm i verdaccio -g
Then you simply go to the core/ng-core
project and publish the library on the default port :
"publish:core:local": "ng build core && cd dist/core && npm publish --registry http://localhost:4873/"
You simply install core from local registry :
npm i core --registry http://localhost:4873/
Do it on both Angular applications.
Both projects are configured to be built in the appropriate public Spring folder. So you simply run build scripts :
"build:shell": "ng build --base-href /ng-shell/ --configuration production",
"build:mfe1": "ng build --base-href /ng-shell/mfe1/ --configuration production",
Run ShellApplication Java class.
You just need to run the application with the proper argument as base path :
--server.servlet.context-path=/ng-shell