diff --git a/github/workflows/e2e.yaml b/.github/workflows/e2e.yaml similarity index 100% rename from github/workflows/e2e.yaml rename to .github/workflows/e2e.yaml diff --git a/github/workflows/format.yaml b/.github/workflows/format.yaml similarity index 100% rename from github/workflows/format.yaml rename to .github/workflows/format.yaml diff --git a/github/workflows/lint.yaml b/.github/workflows/lint.yaml similarity index 100% rename from github/workflows/lint.yaml rename to .github/workflows/lint.yaml diff --git a/github/workflows/test.yaml b/.github/workflows/test.yaml similarity index 100% rename from github/workflows/test.yaml rename to .github/workflows/test.yaml diff --git a/.idea/tailwindcss.xml b/.idea/tailwindcss.xml new file mode 100644 index 0000000..75f8dd8 --- /dev/null +++ b/.idea/tailwindcss.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/angular.json b/angular.json index afb5353..4b064cc 100644 --- a/angular.json +++ b/angular.json @@ -80,7 +80,13 @@ "development": { "optimization": false, "extractLicenses": false, - "sourceMap": true + "sourceMap": true, + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.development.ts" + } + ] } }, "defaultConfiguration": "production" diff --git a/e2e/example.spec.ts b/e2e/example.spec.ts index 3c9516b..54a8a7e 100644 --- a/e2e/example.spec.ts +++ b/e2e/example.spec.ts @@ -4,5 +4,5 @@ test("has title", async ({ page }) => { await page.goto("/"); // Expect a title "to contain" a substring. - await expect(page).toHaveTitle(/StarterAngular19/); + await expect(page).toHaveTitle(/home/i); }); diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 6329900..0899eb1 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -1,5 +1,5 @@ +import { AppComponent } from "@/app/app.component"; import { ComponentFixture, TestBed } from "@angular/core/testing"; -import { AppComponent } from "./app.component"; describe("AppComponent", () => { let component: AppComponent; diff --git a/src/app/app.config.server.ts b/src/app/app.config.server.ts index 2b051f0..631a4c7 100644 --- a/src/app/app.config.server.ts +++ b/src/app/app.config.server.ts @@ -1,6 +1,6 @@ +import { appConfig } from "@/app/app.config"; import { ApplicationConfig, mergeApplicationConfig } from "@angular/core"; import { provideServerRendering } from "@angular/platform-server"; -import { appConfig } from "./app.config"; const serverConfig: ApplicationConfig = { providers: [provideServerRendering()], diff --git a/src/app/app.config.ts b/src/app/app.config.ts index 04e9e56..accbd89 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -1,16 +1,24 @@ -import { ApplicationConfig, provideZoneChangeDetection } from "@angular/core"; +import { routes } from "@/app/app.routes"; +import { GlobalErrorHandler } from "@/app/global-error-handler"; +import { + ApplicationConfig, + ErrorHandler, + provideZoneChangeDetection, +} from "@angular/core"; import { provideClientHydration, withEventReplay, } from "@angular/platform-browser"; import { provideRouter } from "@angular/router"; -import { routes } from "./app.routes"; - export const appConfig: ApplicationConfig = { providers: [ provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), provideClientHydration(withEventReplay()), + { + provide: ErrorHandler, + useClass: GlobalErrorHandler, + }, ], }; diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index fb52ff5..302f9a9 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -1,15 +1,19 @@ import { Routes } from "@angular/router"; -import { HomePageComponent } from "./pages/home-page/home-page.component"; -import { NotFoundPageComponent } from "./pages/not-found-page/not-found-page.component"; export const routes: Routes = [ { path: "", pathMatch: "full", - component: HomePageComponent, + loadComponent: async () => + (await import("@/app/pages/home-page/home-page.component")) + .HomePageComponent, + title: "Home", }, { path: "**", - component: NotFoundPageComponent, + loadComponent: async () => + (await import("@/app/pages/not-found-page/not-found-page.component")) + .NotFoundPageComponent, + title: "Not Found", }, ]; diff --git a/src/app/global-error-handler.ts b/src/app/global-error-handler.ts new file mode 100644 index 0000000..65a360f --- /dev/null +++ b/src/app/global-error-handler.ts @@ -0,0 +1,11 @@ +import { ErrorHandler } from "@angular/core"; + +/** + * Handle uncaught client-side errors. + */ +export class GlobalErrorHandler implements ErrorHandler { + handleError(e: unknown): void { + console.error(e); + alert("An unknown error has occurred. Please try again later."); + } +} diff --git a/src/app/pages/home-page/home-page.component.html b/src/app/pages/home-page/home-page.component.html index 7454417..d5c0066 100644 --- a/src/app/pages/home-page/home-page.component.html +++ b/src/app/pages/home-page/home-page.component.html @@ -1 +1 @@ -

home-page works!

+

Deployment successful!

diff --git a/src/environments/angular-environment.ts b/src/environments/angular-environment.ts new file mode 100644 index 0000000..31e680e --- /dev/null +++ b/src/environments/angular-environment.ts @@ -0,0 +1,3 @@ +export type AngularEnvironment = { + name: "development" | "production"; +}; diff --git a/src/environments/environment.development.ts b/src/environments/environment.development.ts new file mode 100644 index 0000000..6abc799 --- /dev/null +++ b/src/environments/environment.development.ts @@ -0,0 +1,5 @@ +import { AngularEnvironment } from "@/environments/angular-environment"; + +export const environment: AngularEnvironment = { + name: "development", +}; diff --git a/src/environments/environment.ts b/src/environments/environment.ts new file mode 100644 index 0000000..4446d3d --- /dev/null +++ b/src/environments/environment.ts @@ -0,0 +1,5 @@ +import { AngularEnvironment } from "@/environments/angular-environment"; + +export const environment: AngularEnvironment = { + name: "production", +}; diff --git a/src/main.server.ts b/src/main.server.ts index 1f25e8a..39bed44 100644 --- a/src/main.server.ts +++ b/src/main.server.ts @@ -1,6 +1,6 @@ +import { AppComponent } from "@/app/app.component"; +import { config } from "@/app/app.config.server"; import { bootstrapApplication } from "@angular/platform-browser"; -import { AppComponent } from "./app/app.component"; -import { config } from "./app/app.config.server"; const bootstrap = () => bootstrapApplication(AppComponent, config); diff --git a/src/main.ts b/src/main.ts index e272aa3..0d89954 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,6 @@ +import { AppComponent } from "@/app/app.component"; +import { appConfig } from "@/app/app.config"; import { bootstrapApplication } from "@angular/platform-browser"; -import { AppComponent } from "./app/app.component"; -import { appConfig } from "./app/app.config"; bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err), diff --git a/src/server.ts b/src/server.ts index ea24f3d..a75c09e 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,9 +1,9 @@ +import bootstrap from "@/main.server"; import { APP_BASE_HREF } from "@angular/common"; import { CommonEngine, isMainModule } from "@angular/ssr/node"; import express from "express"; import { dirname, join, resolve } from "node:path"; import { fileURLToPath } from "node:url"; -import bootstrap from "./main.server"; const serverDistFolder = dirname(fileURLToPath(import.meta.url)); const browserDistFolder = resolve(serverDistFolder, "../browser"); diff --git a/tsconfig.json b/tsconfig.json index 5525117..bf8b7a0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,11 @@ "moduleResolution": "bundler", "importHelpers": true, "target": "ES2022", - "module": "ES2022" + "module": "ES2022", + "baseUrl": "./", + "paths": { + "@/*": ["src/*"] + } }, "angularCompilerOptions": { "enableI18nLegacyMessageIdFormat": false,