Overview
The ItzHypeR 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 Process
Run the Build Command
Execute the build command from your project root:This command runs
vite build which:- Bundles your React application
- Minifies JavaScript and CSS
- Optimizes assets (images, fonts, etc.)
- Generates production-ready files
Verify Build Output
After building, check the You should see:
dist/ directory:index.html- Entry HTML fileassets/- Bundled JS, CSS, and other assets- Static files from the
public/directory
What Vite Build Does
Vite’s production build process includes several optimizations:Code Splitting
- Automatically splits code into smaller chunks
- Loads components on-demand for faster initial page load
- Vendor dependencies are separated for better caching
Minification
- Removes whitespace and comments
- Shortens variable names
- Reduces bundle size significantly
Asset Optimization
- Images under 4KB are inlined as base64
- Asset filenames include content hashes for cache busting
- CSS is extracted and minified separately
Tree Shaking
- Removes unused code from the final bundle
- Only includes imported functions/components
- Significantly reduces bundle size
Build Configuration
The build is configured invite.config.js:
vite.config.js
The React plugin enables Fast Refresh during development and optimizes React code for production.
Environment Variables
For production builds, you can use environment variables:Creating Environment Files
Using Environment Variables
Access environment variables in your code:Build Optimization Tips
1. Analyze Bundle Size
Install and use the rollup-plugin-visualizer:vite.config.js:
2. Optimize Images
- Use WebP format for better compression
- Implement lazy loading for images
- Consider using
vite-plugin-image-optimizer
3. Code Splitting Strategies
Implement route-based code splitting:4. Reduce Dependencies
- Remove unused packages from
package.json - Use lighter alternatives when possible
- Import only what you need from libraries
Build Verification Checklist
Before deploying, verify:- Build completes without errors
-
npm run previewworks correctly - All routes are accessible
- Images and assets load properly
- Contact form functions (if using EmailJS)
- No console errors in production mode
- Performance is acceptable (use Lighthouse)
Troubleshooting
Build Fails with Memory Error
Increase Node.js memory limit:Assets Not Loading
Ensure your base path is correct invite.config.js: