Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update example app to standalone #4487

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
19 changes: 11 additions & 8 deletions projects/example-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"generators": {},
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:browser",
"executor": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/projects/example-app",
"index": "projects/example-app/src/index.html",
"main": "projects/example-app/src/main.ts",
"polyfills": "projects/example-app/src/polyfills.ts",
"browser": "projects/example-app/src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "projects/example-app/tsconfig.app.json",
"assets": [
"projects/example-app/src/favicon.ico",
Expand All @@ -24,20 +24,23 @@
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
"sourceMap": true
}
},
"defaultConfiguration": "production",
Expand Down
30 changes: 0 additions & 30 deletions projects/example-app/src/app/app-routing.module.ts

This file was deleted.

88 changes: 88 additions & 0 deletions projects/example-app/src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { ApplicationConfig } from '@angular/core';
import { provideHttpClient } from '@angular/common/http';
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';

import { provideStore } from '@ngrx/store';
import { provideEffects } from '@ngrx/effects';
import { provideRouterStore } from '@ngrx/router-store';
import { provideStoreDevtools } from '@ngrx/store-devtools';

import { rootReducers, metaReducers } from '@example-app/reducers';

import { APP_ROUTES } from '@example-app/app.routing';
import { UserEffects, RouterEffects } from '@example-app/core/effects';
import {
provideRouter,
withComponentInputBinding,
withHashLocation,
} from '@angular/router';
import { AuthEffects } from './auth/effects';
import { provideAuth } from '@example-app/auth/reducers';
import { provideLayout } from '@example-app/core/reducers/layout.reducer';

export const appConfig: ApplicationConfig = {
providers: [
provideAnimationsAsync(),
provideHttpClient(),
provideRouter(APP_ROUTES, withHashLocation(), withComponentInputBinding()),

/**
* provideStore() is imported once in the root providers, accepting a reducer
* function or object map of reducer functions. If passed an object of
* reducers, combineReducers will be run creating your application
* meta-reducer. This returns all providers for an @ngrx/store
* based application.
*/
provideStore(rootReducers, {
metaReducers,
runtimeChecks: {
// strictStateImmutability and strictActionImmutability are enabled by default
strictStateSerializability: true,
strictActionSerializability: true,
strictActionWithinNgZone: true,
strictActionTypeUniqueness: true,
},
}),

/**
* The layout feature manages the visibility of the sidenav.
*/
provideLayout(),

/**
* The Auth state is provided here to ensure that the login details
* are available as soon as the application starts.
*
* It could also be part of the `rootReducers`, but is separated
* because of demonstration purposes.
*/
provideAuth(),

/**
* @ngrx/router-store keeps router state up-to-date in the store.
*/
provideRouterStore(),

/**
* Store devtools instrument the store retaining past versions of state
* and recalculating new states. This enables powerful time-travel
* debugging.
*
* To use the debugger, install the Redux Devtools extension for either
* Chrome or Firefox
*
* See: https://github.com/zalmoxisus/redux-devtools-extension
*/
provideStoreDevtools({
name: 'NgRx Book Store App',
// In a production build you would want to disable the Store Devtools
// logOnly: !isDevMode(),
}),

/**
* The provideEffects() function is used to register effect classes
* so they are initialized when the application starts.
*/
provideEffects(UserEffects, RouterEffects, AuthEffects),
],
};
81 changes: 0 additions & 81 deletions projects/example-app/src/app/app.module.ts

This file was deleted.

22 changes: 22 additions & 0 deletions projects/example-app/src/app/app.routing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Routes } from '@angular/router';
sheikalthaf marked this conversation as resolved.
Show resolved Hide resolved

import { authGuard } from '@example-app/auth/services';
import { NotFoundPageComponent } from '@example-app/core/containers';

export const APP_ROUTES: Routes = [
{
path: 'login',
loadChildren: () => import('@example-app/auth/auth.routes'),
},
{ path: '', redirectTo: '/books', pathMatch: 'full' },
{
path: 'books',
loadChildren: () => import('@example-app/books/books.routes'),
canActivate: [authGuard],
},
{
path: '**',
component: NotFoundPageComponent,
data: { title: 'Not found' },
},
];
13 changes: 0 additions & 13 deletions projects/example-app/src/app/auth/auth-routing.module.ts

This file was deleted.

37 changes: 0 additions & 37 deletions projects/example-app/src/app/auth/auth.module.ts

This file was deleted.

10 changes: 10 additions & 0 deletions projects/example-app/src/app/auth/auth.routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Routes } from '@angular/router';
import { LoginPageComponent } from '@example-app/auth/containers';

export default [
{
path: '',
component: LoginPageComponent,
data: { title: 'Login' },
},
] satisfies Routes;
Loading
Loading