Overview
Been is a static React application built with Vite. It can be deployed to any static hosting provider that supports Single Page Applications (SPAs).Build Process
Production Build
Create an optimized production build:- Type checking: Runs
tsc --noEmitto verify TypeScript types - Asset optimization: Minifies and bundles JavaScript, CSS, and assets
- Output generation: Creates static files in the
dist/directory
Build Configuration
The build is configured invite.config.ts:
- Output directory:
dist/(relative to project root) - Assets directory: Assets are placed in the root of
dist/ - Source maps: Generated in development mode only
- Clean build:
emptyOutDirensures old files are removed
Build Output
After building, thedist/ directory contains:
Environment Variables
Production Environment Variables
Been requires a Mapbox API key. Set this before building:Security Considerations
- Mapbox tokens are public and restricted by domain/URL
- Configure allowed URLs in your Mapbox account settings
- Never commit
.envfiles to version control - Use different tokens for development and production
Deployment Platforms
Static Hosting Providers
Been can be deployed to any static hosting provider:- Vercel
- Netlify
- Cloudflare Pages
- GitHub Pages
- AWS S3 + CloudFront
- Azure Static Web Apps
- Google Cloud Storage
Vercel Deployment
- Install Vercel CLI:
- Deploy:
- Configure environment variables in Vercel dashboard:
- Add
VITE_API_KEY_MAPBOXin Settings → Environment Variables
- Add
Netlify Deployment
- Install Netlify CLI:
- Build and deploy:
- Or connect your Git repository in Netlify dashboard with:
- Build command:
pnpm build - Publish directory:
dist - Environment variables:
VITE_API_KEY_MAPBOX
- Build command:
GitHub Pages
- Build the application:
- Deploy to gh-pages branch:
For GitHub Pages, you may need to configure the base URL in
vite.config.ts if deploying to a project page:Docker Deployment
Example Dockerfile for serving with nginx:SPA Configuration
URL Routing
For proper SPA routing, configure your server to redirect all requests toindex.html.
Nginx:
.htaccess):
Verification
Local Preview
Test the production build locally:http://localhost:4173 to verify the build.
Pre-deployment Checklist
Before deploying, ensure:- All tests pass (
pnpm testandpnpm e2e) - No linting errors (
pnpm lint) - Code is properly formatted (
pnpm format) - Production build succeeds (
pnpm build) - Environment variables are configured
- Mapbox token is valid and has correct URL restrictions
- Application loads correctly in preview mode
Performance Optimization
Build Optimizations
Vite automatically applies:- Code splitting: Separates vendor and application code
- Tree shaking: Removes unused code
- Minification: Compresses JavaScript and CSS
- Asset optimization: Optimizes images and other assets
Caching Strategy
Vite includes content hashes in filenames:index-[hash].js- Cache assets indefinitelyindex.html- Serve with no-cache or short TTL
CDN Configuration
For optimal performance:- Serve static assets from a CDN
- Enable gzip/brotli compression
- Set long cache headers for hashed assets
- Set short cache headers for
index.html
Monitoring
Production Monitoring
Consider adding:- Error tracking: Sentry, Rollbar, or similar
- Analytics: Google Analytics, Plausible, or similar
- Performance monitoring: Web Vitals tracking
- Uptime monitoring: UptimeRobot, Pingdom, or similar
Health Checks
Most static hosting providers automatically monitor:- Server uptime
- Response times
- Build/deployment status
Rollback
Most platforms support instant rollbacks:- Vercel: Click “Rollback” on previous deployment
- Netlify: Deploy previous build from Deploys tab
- Manual: Keep previous
dist/builds or Git tags
Troubleshooting
Build Failures
TypeScript errors: Fix type errors reported bytsc
VITE_API_KEY_MAPBOX is set