Build Configuration
The project uses Vite with React and TypeScript:vite.config.ts
Build Commands
The project includes two build modes:package.json:
package.json
The production build optimizes assets, minifies code, and tree-shakes unused dependencies. The output is written to the
dist/ directory.Environment Variables
Create a.env.production file with your production environment variables:
.env.production
Platform-Specific Deployment
Lovable (Recommended)
Lovable provides zero-config deployment:Configure environment variables
Set production env vars in the Lovable dashboard under Project Settings → Environment Variables
Vercel
Vercel Configuration (
vercel.json):
vercel.json
Netlify
Netlify Configuration (netlify.toml):
netlify.toml
The redirect rule ensures React Router works correctly with client-side routing.
Cloudflare Pages
Build Settings:- Build command:
npm run build - Build output directory:
dist - Root directory:
/
AWS S3 + CloudFront
Custom Domain Setup
After deploying, configure your custom domain:Vercel
Vercel
- Go to Project Settings → Domains
- Add your custom domain
- Configure DNS records as shown
- Wait for SSL certificate provisioning
Netlify
Netlify
- Go to Site Settings → Domain Management
- Add custom domain
- Update DNS records to Netlify nameservers
- Enable HTTPS (automatic with Let’s Encrypt)
Cloudflare Pages
Cloudflare Pages
- Go to Custom Domains
- Add your domain
- Update DNS records (automatic if using Cloudflare DNS)
- SSL is automatic
Testing the Deployment
After deployment, verify:Check environment variables
Open browser DevTools → Console and run:Should output your Supabase URL (not
undefined)Test Supabase connection
Navigate to any page that fetches data. Check Network tab for successful API calls to Supabase
Verify edge functions
Create a test topic and confirm data is fetched from X/Reddit via edge functions
Performance Optimization
Asset Optimization
Vite automatically:- Minifies JavaScript and CSS
- Tree-shakes unused code
- Code-splits routes with dynamic imports
- Optimizes images and fonts
CDN Caching
Configure cache headers for static assets:vite.config.ts
Bundle Analysis
Analyze bundle size:stats.html to identify large dependencies.
Troubleshooting
Blank page after deployment
Blank page after deployment
Cause: Incorrect base path or missing environment variablesSolution:
- Check browser console for errors
- Verify all
VITE_*env vars are set - Ensure
index.htmlis in the root ofdist/
404 on page refresh
404 on page refresh
Cause: Server not configured for SPA routingSolution: Add redirect rule to serve
index.html for all routes (see platform-specific configs above)Environment variables undefined
Environment variables undefined
Cause: Variables not prefixed with
VITE_ or not set during buildSolution:- Ensure all vars start with
VITE_ - Rebuild after adding env vars
- Clear build cache:
rm -rf dist node_modules/.vite
CORS errors
CORS errors
Cause: Supabase edge functions not allowing your domainSolution: Check
supabase/config.toml and ensure CORS headers include your production domainCI/CD Pipeline
Example GitHub Actions workflow:.github/workflows/deploy.yml
Next Steps
Deploy Edge Functions
Deploy backend edge functions to Supabase
Configure Secrets
Set up production API keys and secrets