Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MateoRiosdev/Free-TTS-VozCraft/llms.txt
Use this file to discover all available pages before exploring further.
Building for Production
This guide covers building VozCraft for production deployment. Vite provides highly optimized builds with automatic code splitting, minification, and asset optimization.Quick Start
Build VozCraft for production with a single command:dist/ directory, ready for deployment.
Build time: Typically 5-15 seconds on modern hardware.Output size: ~150-200 KB (gzipped) for the complete application.
Build Process
The build Script
Thebuild command is defined in package.json:
package.json
Build Configuration
Vite usesvite.config.js for build settings:
vite.config.js
This is the minimal configuration. VozCraft uses Vite’s intelligent defaults for optimal production builds.
What Happens During Build
Dependency resolution
Vite analyzes all imports and dependencies:All dependencies are traced and bundled.
Code minification
JavaScript is minified using esbuild:
Minification savings: Typically 40-60% size reduction.
Asset optimization
Images and other assets are optimized:
- Images: Compressed and copied to
dist/assets/ - Fonts: Inlined or copied based on size
- SVG: Minified and optimized
CSS processing
Inline styles are extracted and optimized:
VozCraft uses inline styles exclusively, so no separate CSS file is generated.
Code splitting
Vite automatically splits code for optimal loading:
- Vendor chunks: React and React-DOM in separate chunks
- Dynamic imports: Lazy-loaded components (if any)
- Entry point: Main application code
Build Output
Directory Structure
After building, thedist/ directory contains:
File Sizes
Typical production build sizes:| File | Size (uncompressed) | Size (gzipped) |
|---|---|---|
| index.html | ~1 KB | ~500 B |
| index-[hash].js | ~450 KB | ~150 KB |
| React vendor | ~140 KB | ~45 KB |
| Total JavaScript | ~590 KB | ~195 KB |
| Images | ~210 KB | ~210 KB |
| Total | ~800 KB | ~405 KB |
Gzip compression is typically applied by web servers (Nginx, Apache, CDNs) automatically. The gzipped size is what users actually download.
Optimized index.html
The builtindex.html includes minified content and hashed asset references:
dist/index.html
Key changes from development
Key changes from development
- Module script: Points to hashed bundle
- Crossorigin: Enables CORS for module loading
- Inline styles removed: Extracted to JS bundle
- Whitespace minified: Reduced HTML size
Advanced Build Configuration
Custom Vite Configuration
You can extendvite.config.js for custom build behavior:
vite.config.js
- Source Maps
- Output Directory
- Base URL
- Browser Targets
Enable source maps for production debugging:Options:
true: Separate .map files'inline': Inline source maps (larger bundle)'hidden': Source maps without reference (for error tracking)false: No source maps (smallest bundle)
Environment-Specific Builds
Create different builds for different environments:vite.config.js
Build Optimization Strategies
1. Code Splitting
Split large components into separate chunks:src/App.jsx
2. Tree Shaking
Vite automatically removes unused code:Tree shaking requirements:
- Use ES modules (
import/export) - Avoid CommonJS (
require) - Use named imports when possible
3. Asset Optimization
Image Optimization
vite.config.js
Requires installing:
npm install -D vite-plugin-imageminFont Loading
VozCraft loads Google Fonts. Consider self-hosting for better performance:4. Bundle Analysis
Analyze bundle size to identify optimization opportunities:vite.config.js
Build Scripts
Custom Build Scripts
Add specialized build scripts topackage.json:
package.json
- Clean Build
- Analyze Build
- Staging Build
Remove old build before creating new one:Ensures no stale files remain in
dist/.Performance Budgets
Set performance budgets to catch bundle bloat:vite.config.js
Testing the Build
Local Preview
Test the production build locally:dist/ directory at http://localhost:4173.
Preview server features:
- Simulates production environment
- Serves compressed files
- Uses production URLs
- Tests PWA functionality
Serve with Different Servers
- Python HTTP Server
- Node http-server
- Nginx
Build Checklist
Check build output
Verify:
- No build errors or warnings
- Bundle sizes are reasonable
- All assets copied to
dist/
Test locally
- Speech synthesis works
- Audio download works
- History persists
- PWA manifest loads
- Dark/light theme works
Check console
Open DevTools and verify:
- No JavaScript errors
- No 404s for missing assets
- No CSP violations
Test on mobile
- Open preview URL on phone
- Test PWA installation
- Verify responsive design
- Test touch interactions
Common Build Issues
Build fails with syntax errors
Build fails with syntax errors
Cause: Using features not supported by target browsers.Solution:Or add polyfills for older browsers.
vite.config.js
Assets not found after build
Assets not found after build
Cause: Incorrect asset paths or base URL.Solution:Use root-relative paths:
vite.config.js
Bundle size too large
Bundle size too large
Causes:
- Large dependencies
- Unused code not tree-shaken
- Unoptimized images
- Analyze bundle:
- Lazy load heavy components:
- Replace large dependencies with smaller alternatives
- Enable compression on server (gzip/brotli)
Out of memory during build
Out of memory during build
Solution:Or in
package.json:Continuous Integration
GitHub Actions
.github/workflows/build.yml
Next Steps
Deployment
Deploy your build to production
PWA Setup
Optimize PWA configuration
