All the code powering my personal website: https://valerymelou.com.
This is an Nx monorepo with an Angular application (apps/www) and several libraries.
- Node.js 20+ (LTS recommended)
- npm 9+/pnpm/yarn (examples below use
npxandyarn)
Optional for deployment:
- Firebase CLI:
npm i -g firebase-tools
yarn installSome features (Contentful CMS, absolute URLs, etc.) are configured via environment variables. Only variables prefixed with VM_ are exposed to the browser at build time.
Required:
VM_CONTENTFUL_SPACEVM_CONTENTFUL_ACCESS_TOKENVM_CONTENTFUL_ENVIRONMENT(e.g.master)
Export them in your shell before serving/building (macOS zsh):
export VM_CONTENTFUL_SPACE="<your_space_id>"
export VM_CONTENTFUL_ACCESS_TOKEN="<your_cda_access_token>"
export VM_CONTENTFUL_ENVIRONMENT="master"Notes:
- The dev server and builds read from your process environment. If you prefer, add these exports to your shell profile (e.g.
~/.zshrc). - The app includes an env-var plugin that injects only
VM_*variables into the client bundle.
npx nx serve wwwThis runs Angular’s dev server with HMR. The app is available at http://localhost:4200 by default.
- Run all tests:
npx nx test - Lint all projects:
npx nx lint
- Build the app (production):
npx nx build www --configuration=production
- Serve the built app statically (after a build):
npx nx serve-static www
This project ships with a firebase.json configured to serve the built browser output from dist/apps/www/browser with SPA rewrites.
- Install the Firebase CLI and log in:
npm i -g firebase-tools
firebase login- Select or set your Firebase project (skip if already configured):
firebase use --add- Ensure the required env vars are set (see above), then build:
npx nx build www --configuration=production- Deploy Hosting:
firebase deploy --only hostingThat’s it—Firebase Hosting will upload the contents of dist/apps/www/browser and apply SPA rewrites (/** -> /index.html).
Create a temporary preview deployment without affecting production:
firebase hosting:channel:deploy stagingYou’ll get a unique preview URL. You can also set an expiration:
firebase hosting:channel:deploy staging --expires 7d- Environment variables must be present when building. Hosting is static and will serve whatever was baked into the bundle at build time.
- If you run deployment from CI, export the
VM_...variables in your CI environment before runningnx build.