What is the best architecture for Angular Ionic

How to share code between angular and Ionic application ? My goal is to reuse as many code as possible, especially business logic between angular universal app and Ionic app that should be deployed on the stores. I also need to use this mobile app as mobile version of web app (for the users that browse the website with their mobile).

I found some solutions to share code between Ionic and Angular, for example the monorepo concept user Nx (https://itnext.io/building-scalable-multi-platform-projects-with-angular-and-nx-a13b40885e54)
It sounds good but in this case, Ionic app is totally separated, then the mobile web version is not handled.

The other solution is to install Ionic in the angular projet and create different components (for desktop and mobile) using the same codebase and display the right component base on the type of device. Sounds good but it mean that the compiled application will contains all the desktop code (that will be never used) ā€¦ Iā€™m not sure that is the right solution.

What is the bast practice for this case ?

1 Like