Overview
The MND web frontend is built with React 19, TypeScript, and Vite. It compiles to static files that can be hosted on any web server or CDN.Prerequisites
- Node.js 18+
- npm or yarn
- Backend API running (see Backend Setup)
Local Development
1. Install Dependencies
2. Configure Environment
Create.env file:
3. Start Development Server
http://localhost:5173 by default.
Development features:
- Hot module replacement (HMR)
- Fast refresh
- Source maps
- Error overlay
Building for Production
1. Set Production Environment
Create.env.production:
2. Run Build
dist/:
- Code splitting
- Tree shaking
- Minification
- Asset hashing for cache busting
- Gzip/Brotli compression ready
3. Test Production Build Locally
http://localhost:4173.
Deployment Options
Option 1: Vercel (Recommended)
Vercel is optimized for Vite and React apps.Deploy via CLI
- Install Vercel CLI:
- Login:
- Deploy:
- For production:
Deploy via Git Integration
- Push code to GitHub/GitLab/Bitbucket
- Go to vercel.com
- Click “New Project”
- Import your repository
- Configure:
- Framework Preset: Vite
- Root Directory:
MND-frontend - Build Command:
npm run build - Output Directory:
dist
- Add environment variables:
VITE_API_BASE_URL: Your backend URL
- Deploy
vercel.json):
Option 2: Netlify
Deploy via CLI
- Install Netlify CLI:
- Login:
- Deploy:
Deploy via Git Integration
- Push to GitHub/GitLab/Bitbucket
- Go to netlify.com
- Click “New site from Git”
- Configure:
- Base directory:
MND-frontend - Build command:
npm run build - Publish directory:
dist
- Base directory:
- Add environment variables
- Deploy
netlify.toml):
Option 3: Static Hosting (Nginx, Apache)
Nginx Configuration
- Build the app:
- Copy
dist/to web server:
- Configure Nginx (
/etc/nginx/sites-available/mnd):
- Enable and restart:
Apache Configuration
.htaccess in dist folder:
Option 4: AWS S3 + CloudFront
- Create S3 bucket
- Enable static website hosting
- Upload
dist/contents - Configure CloudFront distribution
- Point to S3 origin
Environment Configuration
API Base URL
Configure based on deployment: Same origin (frontend and backend on same domain):CORS Configuration
If frontend and backend are on different domains, configure CORS in backend:Performance Optimization
Build Size Analysis
Analyze bundle size:vite.config.ts:
Code Splitting
Vite automatically splits code. For manual control:Asset Optimization
- Images: Use WebP format, compress with tools like ImageOptim
- Fonts: Subset fonts to include only needed characters
- SVG: Optimize with SVGO
Caching Strategy
Cache-Control headers:SSL/HTTPS
Let’s Encrypt (Free)
Vercel/Netlify
Automatic HTTPS included.Monitoring
Error Tracking
Add Sentry for error tracking:Analytics
Add Google Analytics:Troubleshooting
Build Fails
API Requests Fail
Check CORS and API URL:404 on Refresh
Ensure server is configured for SPA routing (see Nginx/Apache config above).Blank Page After Deploy
Check browser console for errors. Common issues:- Incorrect
basein vite.config.ts - Missing environment variables
- API CORS errors
Deployment Checklist
- Environment variables configured
- Production build succeeds
- API URL points to production backend
- CORS configured on backend
- HTTPS/SSL enabled
- Caching headers configured
- Error tracking enabled
- Analytics configured
- Custom domain configured
- Tested on mobile devices
- Tested on multiple browsers