Prerequisites:
- Node.js version 19 or higher
- Project dependencies installed via
npm install
Build Configuration
The project uses a minimal Vite configuration located invite.config.js:
vite.config.js
- React Fast Refresh via
@vitejs/plugin-reactfor instant component updates - Tailwind CSS v4 integration via
@tailwindcss/vitefor utility-first styling - Automatic optimization including code splitting, tree shaking, and minification
Building for Production
Install dependencies
Ensure all project dependencies are installed:This installs all packages defined in
package.json, including:- React 19.2.0 with the latest features
- Vite 7 for blazing-fast builds
- Tailwind CSS 4 for styling
- Motion library for animations
- React Router DOM for navigation
- i18next for internationalization (EN, ES, FR)
Run the build command
Execute the production build:This runs
vite build which:- Compiles all JSX/JS files into optimized JavaScript
- Processes and minifies CSS (including Tailwind utilities)
- Optimizes images and static assets from
/public - Generates production bundles with code splitting
- Creates a
dist/directory with deployment-ready files
Build Optimization Features
Vite automatically applies several optimizations during the build:Code Splitting
Large dependencies are automatically split into separate chunks, reducing initial load time. React Router routes can be lazy-loaded for better performance.Tree Shaking
Unused code is automatically removed from the final bundle. Only the icons you import from@tabler/icons-react and lucide-react are included.
Minification
JavaScript and CSS are minified using esbuild, significantly reducing file sizes while maintaining functionality.Asset Optimization
Images and other static assets are optimized and include content hashes for long-term caching.Preview Build Locally
Before deploying, preview the production build locally:Start the preview server
dist/ folder on http://localhost:4173 using Vite’s preview server.Test the production build
Open
http://localhost:4173 in your browser and verify:- All pages load correctly
- Navigation works (React Router)
- Language switching functions (i18next with EN, ES, FR)
- Theme toggle works (next-themes)
- Animations render properly (motion)
- Analytics tracking is active (@vercel/analytics)
Development vs Production
| Feature | Development (npm run dev) | Production (npm run build) |
|---|---|---|
| Speed | Instant HMR updates | Optimized for runtime performance |
| Bundle size | Unoptimized, larger | Minified, tree-shaken |
| Source maps | Detailed for debugging | Minimal or excluded |
| Environment | development mode | production mode |
| Hot reload | Enabled | N/A |
Build Scripts Reference
All available build-related scripts frompackage.json:
Troubleshooting
Build fails with module resolution errors
Build fails with module resolution errors
This may indicate missing dependencies or version conflicts.Solution:
- Delete
node_modules/andpackage-lock.json - Run
npm installto reinstall dependencies - Ensure Node.js version is 19 or higher:
node --version
Build succeeds but site doesn't work in preview
Build succeeds but site doesn't work in preview
Check for environment-specific code that behaves differently in production.Solution:
- Check browser console for JavaScript errors
- Verify all imports use correct paths (case-sensitive)
- Ensure
index.htmlcorrectly references the build output - Check that all environment variables are set (if using any)
Build output is too large
Build output is too large
Large bundle sizes can impact load times.Solution:
- Use dynamic imports for large dependencies
- Analyze bundle with
vite-bundle-visualizer - Ensure tree-shaking works by using ES modules imports
- Consider lazy-loading routes with React Router
Next Steps
After building your application:Deploy to Vercel
Learn how to deploy your build to Vercel with automatic deployments.
Development Guide
Set up your local development environment.