Local Development
When to Use
Use this skill when running the web app or functions locally, troubleshooting emulator issues, or running Storybook.
Important
The user runs functions and web app locally for testing. Claude writes code and creates PRs -- Claude does NOT deploy or run dev servers.
Running Functions Locally (user runs this)
bash1npx nx run functions:serve
This command:
- Builds the functions
- Copies
.env.devtodist/apps/functions/.env - Starts watch mode for rebuilds (background)
- Runs
firebase serve --only functions --project=devon port 5001
Running Web App Locally (user runs this)
bash1npx nx run maple-spruce:serve
Runs on http://localhost:3000
Running Storybook
bash1npx nx run maple-spruce:storybook 2# Opens http://localhost:6006
Building Storybook:
bash1npx nx run maple-spruce:build-storybook 2# Output: dist/storybook/maple-spruce
Running Tests
bash1npm test
Deployment
User decides when to deploy to dev. Production deploys automatically via CI/CD on merge to main.
Troubleshooting Local Functions
Emulator prompts for environment variables
The Firebase emulator is not finding the .env file. This happens when:
- The build clears
dist/apps/functions/before the.envis copied - A stale watch process is interfering
Fix:
bash1# Kill any stale processes 2pkill -f "firebase serve" 3pkill -f "nx run functions" 4 5# Clean and restart 6rm -rf dist/apps/functions 7npx nx run functions:serve
Why this happens:
- Firebase reads
.envfromdist/apps/functions/ - The
nx run functions:buildclears this directory - The serve command copies
.env.devafter build, before starting the emulator - If ordering is wrong or stale processes exist, the emulator starts without the
.env
Key indicator it's working:
i functions: Loaded environment variables from .env.