-
npm run prerenderwill cause 301 Redirect in Firebase HostingSolution add this to the `firebase.json` file ``` { "hosting": { "trailingSlash": false } } ```
- build the library
npm run build-library
2. build the application
npx ng build --configuration production
-
build the application
npm run prerendernote: There is no guarantee that Googlebot will crawl our website with JavaScript enabled. Our findings show that:
- Googlebot may crawl your website with JavaScript enabled, and you can find the website's content on Google.
- However, if Googlebot crawl your website again, it may crawl your website with JavaScript disabled. Consequently, you will not find the website's content on Google.
So, it is recommended to use SSR.
npm run prerenderis only for development. It's not for production. -
deploy the application
npx firebase-tools deploy
srcis Angular Application.projects/common/pipesis an Angular Library.projects/features/experienceis an Angular Library.projects/features/eventis an Angular Application.
Clean Architecture is a way to let back end do their stuff and front end also do their own stuff.
- The data layer can change as the back end like.
GetEventByIdResponseBody.ts
export interface GetEventByIdResponseBody {
id?: string
name?: string
description?: string
}
- The domain layer can change as the front end like.
EventData.ts
export interface EventData {
id: string;
name: string;
}
notice that the domain layer:
-
do not need the
descriptionkey. -
the keys do not have
optionalvalue.this is mandatory. this is because what is inside
EvenDatamust be exist and not be optional, or expected when things do not go wrong, it will be used for rendering the presentation layer or to execute the business logic.although things can happen i.e. server do not response, etc. it's the front end job to handle such cases.
event-page.component.ts
export class EventPageComponent implements OnInit {
event?: EventData;
constructor(
route: ActivatedRoute,
getEventById: GetEventByIdService,
) {
let id = route.snapshot.paramMap.get("id") ?? undefined;
if (id == undefined) { return }
this.event = getEventById.call(id)
}
ngOnInit(): void {
}
}
This project was generated with Angular CLI version 13.3.11.
Run ng serve for a dev server. Navigate to http://localhost:4200/. The application will automatically reload if you change any of the source files.
Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.
Run ng build to build the project. The build artifacts will be stored in the dist/ directory.
Run ng test to execute the unit tests via Karma.
Run ng e2e to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
To get more help on the Angular CLI use ng help or go check out the Angular CLI Overview and Command Reference page.