I have an application with two very large styles sheets:
userA.scss
userB.scss
One of these style sheets could look like:
@import 'something';
.d { }
These two style sheets are legacy style sheets which contain many tens of thousands of lines (yes, really) and cannot load at the same time since they conflict in their rules, as such I load them via the CSS import in each module's SCSS like so:
@import "src/assets/scss/dashboard";
Within a module's/component's scss
file.
Now, the problem I am seeing is that each time I use said import Angular has to recompile and re-evaluate this file making builds times exponentially longer depending on the number of times I include each of these files in modules/components. For example: if I make one of the style sheets only load once for the application I can shave anything up to 6 minutes build time from my SaaS provided CI/CD.
I want to include these two only once each in my application.
I immediately turned to modules, however I have a router like:
const routes: Routes = [
{
path: 'a',
children: [
{
path: 'a',
loadChildren: () => import('./layout-c/a.module').then(m => m.LayoutModule),
},
],
},
{
path: 'b/:id',
loadChildren: () => import('./layout-b/layout-b.module').then(m => m.LayoutBModule),
},
{
path: 'c',
loadChildren: () => import('./layout-c/sign-up-c/signup-c.module').then(m => m.SignupCModule)
},
{
path: 'd',
loadChildren: () => import('./layout-d/layout-d.module').then(m => m.LayoutDModule),
},
{
path: 'e',
loadChildren: () => import('./layout-admin/layout-e.module').then(m => m.LayoutEModule),
},
{
path: 'f/:id',
loadChildren: () => import('./layout-f/layout-f.module').then(m => m.LayoutFModule),
},
{
path: '',
loadChildren: () => import('./layout/layout.module').then(m => m.LayoutModule),
},
{ path: '**', redirectTo: '/', pathMatch: 'full' }
];
And what I need is a way of using userA.scss
in both path a
and c
and only if they are activated.
I wanted to use a common module which would be loaded once and so the SCSS only compiled once but I am really at a loss how to. I was thinking maybe I could somehow make a router group that could encompass both of these routes.
Is there anyway I can achieve this to make large style sheets only compile once?