Overview
The Psi Lime Portfolio uses Vite as its build tool, which provides fast and optimized production builds. This guide covers everything you need to know about building your portfolio for production.Build Command
To create a production build of your portfolio, run:vite build, which:
- Bundles your application for production
- Minifies JavaScript and CSS
- Optimizes assets (images, fonts, etc.)
- Generates source maps
- Outputs everything to the
distfolder
Build Output
Output Structure
After building, you’ll find the production files in thedist/ directory:
Vite automatically adds content hashes to filenames for optimal caching. Each time you build, the hash changes only for modified files.
Output Size
The build process includes several optimizations:- Code splitting: Splits code into smaller chunks for faster loading
- Tree shaking: Removes unused code
- Minification: Reduces file sizes
- Asset optimization: Compresses images and other assets
Environment Variables
Production Environment Variables
If you need to use environment variables in production, create a.env.production file:
.env.production
Accessing Environment Variables
In your code, access environment variables using:Build Optimization Tips
1. Analyze Bundle Size
To understand what’s in your build, you can use bundle analysis tools:vite.config.js:
2. Lazy Load Routes
Optimize initial load time by lazy loading routes:3. Optimize 3D Assets
Since this portfolio uses Three.js and GLB models:- Compress GLB files using tools like gltf-pipeline
- Use Draco compression for meshes
- Optimize texture sizes and formats
4. Configure Build Options
Customize your build invite.config.js:
Preview Production Build
Before deploying, preview your production build locally:The preview server serves the
dist folder exactly as it would be served in production, making it perfect for final testing.Troubleshooting
Build Fails with Memory Error
If your build fails due to memory issues:Assets Not Loading
Ensure yourvite.config.js includes the correct asset types:
Source Maps in Production
If you want to disable source maps in production:Next Steps
Deploy to GitHub Pages
Learn how to deploy your built portfolio to GitHub Pages
Customization
Customize colors, styling, and content for your portfolio