Alex Arvanitidis
Alex Arvanitidis

Reputation: 4464

Angular 8 - Create multi-app structure sharing same app module

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:

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

Answers (2)

Arne
Arne

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

Alexander Trakhimenok
Alexander Trakhimenok

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

Related Questions