3.3 KiB
3.3 KiB
Copilot / AI coding agent instructions — portfolio-admin
Keep this short and actionable. Reference files below when making edits.
Big picture
- This is an Angular 20 standalone application (no NgModule). The app bootstraps with
bootstrapApplicationinsrc/main.tsand usesappConfig(src/app/app.config.ts) for providers. - Server-side rendering (SSR) is enabled via
@angular/ssr. Server entry and Express integration live insrc/server.ts. The SSR configuration mergesappConfigwithconfigfromsrc/app/app.config.server.ts.
Key workflows (commands you can run)
- Start dev server (live reload):
npm run start
- Build for production (browser + server artifacts go to
dist/portfolio-admin):
npm run build
- Run SSR server from built artifacts (package.json):
npm run serve:ssr:portfolio-admin
# which runs: node dist/portfolio-admin/server/server.mjs
Tests
- Unit tests use Karma (configured via
angular.json):
npm run test
Project-specific patterns & conventions
- Standalone components only. Example:
src/app/app.tsuses@Component({ ... imports: [RouterOutlet] })and signals (signal('...')) instead of classic NgModule state. - Routing: routes are defined in
src/app/app.routes.ts(currently empty array). Server-side routes for SSR are insrc/app/app.routes.server.tsand useRenderMode.Prerenderby default. - Hydration: client hydration and event replay are enabled in
src/app/app.config.tsviaprovideClientHydration(withEventReplay())— keep event handlers idempotent where possible. - Styling: SCSS is used project-wide. Components expect
.scssfiles; Prettier settings for HTML are inpackage.json.
Integration points & important files
src/server.ts— Express +AngularNodeAppEnginehandler. Static files served fromdist/.../browserandreqHandleris exported for hosting.src/main.server.ts— SSR bootstrap used by server builds.package.json— scripts of interest:start,build,test,serve:ssr:portfolio-admin.angular.json— build targets and SSR options (outputMode: "server",serverentry, andssr.entry).
Editing guidance / examples
- Add an API endpoint (server-side): edit
src/server.tsand addapp.get('/api/...', (req,res)=>{...}). Keep the handler pure and return JSON; SSR handler sits after static middleware. - Add a route (client + server): update
src/app/app.routes.tswith the newRouteand ensure any server prerender behavior is acceptable (serverRoutes uses**prerender by default). - When changing providers, update
src/app/app.config.ts(client) andsrc/app/app.config.server.ts(server merge) if the provider is required at SSR time.
What NOT to change without confirming
- The SSR glue in
src/server.tsand theAngularNodeAppEngineusage — small mistakes here will break server rendering. If adding features, keep existing request flow (static -> SSR handler). import.meta.dirnameusage insrc/server.tsimplies ESM-style builds. Don't switch CommonJS unless you also adjust build outputs andpackage.jsonfields.
If anything is unclear or you need more examples (routing, adding an API, or running SSR locally), tell me which area and I'll expand the file with a short example patch.