Overview
BoxApp is a React + TypeScript application built with Vite, designed to be deployed as a static site with Supabase as the backend. This guide covers the complete deployment process from build to production.Prerequisites
Before deploying, ensure you have:- Node.js 18+ installed
- A Supabase project (local or cloud)
- A hosting platform account (Vercel, Netlify, or similar)
- Access to your repository
Build Configuration
Build Scripts
BoxApp uses the following npm scripts defined inpackage.json:
Vite Configuration
The build is configured invite.config.ts with path aliases and server settings:
Deployment Process
Install Dependencies
Install all required packages before building:This installs all production and development dependencies including React, Vite, TypeScript, and Supabase client.
Configure Environment Variables
Set up your environment variables for production. Create a
.env.production file or configure them in your hosting platform:Run Database Migrations
Before deploying, ensure all database migrations are applied to your production Supabase instance:
Build the Application
Run the production build command:This command:
- Runs TypeScript compiler (
tsc) to check for type errors - Builds the application using Vite
- Outputs static files to the
dist/directory
The build will fail if there are any TypeScript errors. Fix all type errors before proceeding.
Test the Build Locally
Preview the production build locally before deploying:This starts a local server serving the built files from
dist/.Deploy to Hosting Platform
Deploy the
dist/ directory to your chosen hosting platform. See the Hosting Guide for platform-specific instructions.Continuous Deployment
Automated Builds
For automated deployments, configure your CI/CD pipeline with these steps:Environment-Specific Builds
You can maintain different environment configurations:.env.development- Local development.env.staging- Staging environment.env.production- Production environment
Build Optimization
Code Splitting
Vite automatically handles code splitting. Optimize further by:- Using dynamic imports for routes
- Lazy loading heavy components
- Splitting vendor bundles
Asset Optimization
vite.config.ts
Troubleshooting
Build Fails with TypeScript Errors
Runnpm run lint to identify and fix TypeScript issues:
Environment Variables Not Working
Ensure environment variables are prefixed withVITE_:
Build Output Too Large
- Check bundle size with
npm run build -- --mode production - Analyze chunks with
vite-bundle-visualizer - Remove unused dependencies
- Optimize images and assets
Routing Issues After Deployment
Ensure your hosting platform is configured for SPA routing. Most platforms require a redirect rule to serveindex.html for all routes. See the Hosting Guide for platform-specific configuration.
Next Steps
- Supabase Setup - Configure your Supabase backend
- Hosting Guide - Platform-specific deployment instructions
- Environment Variables - Detailed environment setup