Skip to content

Commit

Permalink
build: lazy load components.
Browse files Browse the repository at this point in the history
  • Loading branch information
poirierlouis committed Jul 30, 2024
1 parent 555f8dd commit 462eb78
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
}
],
"outputHashing": "all",
"namedChunks": true,
"serviceWorker": "ngsw-config.json"
},
"development": {
Expand Down
7 changes: 5 additions & 2 deletions src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {provideHttpClient} from "@angular/common/http";
import {MAT_FORM_FIELD_DEFAULT_OPTIONS} from "@angular/material/form-field";
import {HAMMER_GESTURE_CONFIG, HammerGestureConfig, HammerModule} from "@angular/platform-browser";
import {provideAnimationsAsync} from '@angular/platform-browser/animations/async';
import {provideRouter} from '@angular/router';
import {PreloadAllModules, provideRouter, withPreloading} from '@angular/router';
import {MAT_SNACK_BAR_DEFAULT_OPTIONS} from "@angular/material/snack-bar";
import {NgxColorsModule} from "ngx-colors";

Expand All @@ -13,7 +13,10 @@ import {provideServiceWorker} from '@angular/service-worker';

export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes),
provideRouter(
routes,
withPreloading(PreloadAllModules)
),
provideAnimationsAsync(),
provideHttpClient(),

Expand Down
6 changes: 2 additions & 4 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {Routes} from '@angular/router';
import {ReadmeComponent} from "./pages/readme/readme.component";
import {EditorComponent} from "./pages/editor/editor.component";

export const routes: Routes = [
{path: '', redirectTo: 'readme', pathMatch: 'full'},
{path: 'readme', component: ReadmeComponent},
{path: 'editor', component: EditorComponent},
{path: 'readme', loadComponent: () => import('./pages/readme/readme.component').then(c => c.ReadmeComponent)},
{path: 'editor', loadComponent: () => import('./pages/editor/editor.component').then(c => c.EditorComponent)},
];

0 comments on commit 462eb78

Please sign in to comment.