You can change the template and style files at the compilation level as well. We use different templates and styles due to environment variables. For large projects, this approach happened to be more clear for us.
First, we add two fields to the environment.cs files like:
export const environment = {
production: false,
componentTemplateFile: './tenants/tenant-name.html',
componentStyleFile: './tenants/tenant-name.scss',
...
}
Then, while declaring the components instead of using inline strings we use those environment variables like:
@Component({
selector: 'app-enroll-footer',
templateUrl: environment.componentTemplateFile,
styleUrls: [environment.componentStyleFile]
})
export class EnrollFooterComponent implements OnInit, OnDestroy {
...
Lastly, instead of adding files to the root of the component folder, we have a child folder named tenants, and the template and style files are located under that with the names declared in the environment.cs files.
Example folder structure:
enroll-footer/
enroll-footer/enroll-footer.component.ts
enroll-footer/tenants/tenant-name.html
enroll-footer/tenants/tenant-name.scss
enroll-footer/tenants/other-tenant-name.html
enroll-footer/tenants/other-tenant-name.scss
When we change the environment variables (for another configuration) to other-tenant-name, the angular cli basically uses these files while compiling.