Reputation: 4464
I have this requirement to create 5 apps (Ionic 4/Angular 8) with 90% the same code, but small differences. So what I'm trying to implement is something like the following tree:
projects/
app1/
app2/
app3/
app4/
main/
In the app1, app2 etc. I was planning to have only:
global.scss
, so that I change the global styles of the underlying applications just by changing some variables. angular.json
to define the app name and how to build/runtsconfig.json
, where I define in the compilerOptions.paths: '@main/*': ['../main/src']
, so that I can import anything I want from the main appmain.ts
to use the AppModule
from the main
app.The main
is a totally functioning app on its own.
Is there a way in Angular 8 to do that and re-use the app from main
and just change some scss and possibly override some modules if needed?
I've seen tutorials about using the ng generate lib library
and then re-use all the components from there, but that would make me duplicate all the code and that's what I want to avoid.
Upvotes: 1
Views: 799
Reputation: 852
An angular cli multi-project setup basically can reuse any code from any project. So you create your whole app in your lib, and all you have to duplicatie is your app.module. If you decently modularized your app that's no issue at all.
So yeah;
ng generate application <application-name>
And
ng generate library <library-name>
Are your friends.
Upvotes: 3
Reputation: 6278
You can reference code in ‘main’ from ‘appN’ so should not be a problem. You can import common TS & scss files.
I reuse in similar way a set of common components across few apps.
Upvotes: 0