I have an Angular 5 app, in a .NET core project, that is used by several customers. All of which would like different features and different look. I have tried few things to accomplice this. Firstly I had every company have it's on folder structure for their pages and their own Module. Then I could choose what share component should be on each page which lives in a shared module. I would still use the AppModule as the root module and the App Component with conditional master tags to load the site correctly. The scss/Sass/css would be defined in the "master" page of each brand.
For instance... etc...
All this worked correctly except that the css was still loading from brands that weren't being "loaded". So, they were being compiled although they would never be used.
So I went to another solution... to skip the AppModule as the root module and bootstrap the selected brand module (and use that as a root module) instead.. hoping that this would fix the problem. So in this example which works but when I add the condition to bootstrap brand2 (although the brand is brand1 in the environment) the scss get's compiled and I'm again at square 1. Help would be greatly appreciated.
import 'zone.js';
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { Brand1Module } from "./brand/brand1.module";
import { environment } from "./environments/environment";
import { Brand2Module } from "./brand/brand2.module";
if (environment.production == true)
enableProdMode(); // FOR PRODUCTION
if (environment.brand === "brand1")
{
platformBrowserDynamic().bootstrapModule(Brand1Module);
}
else if (environment.brand === "brand2") {
// If I leave this part below out, the CSS won't be compiled
platformBrowserDynamic().bootstrapModule(Brand2Module);
}