Frontend Stack
The project uses a modern frontend stack configured inpackage.json:9-16:
Key Dependencies
- Vite 7.0.7: Lightning-fast build tool and dev server
- Tailwind CSS 4.0: Utility-first CSS framework
- Laravel Vite Plugin 2.0: Seamless Laravel integration
- Axios 1.11: HTTP client for API requests
- Concurrently 9.0: Run multiple commands in parallel
Vite Configuration
The Vite configuration is defined invite.config.js:1-27:
Configuration Details
Entry Points (vite.config.js:8)
resources/css/app.css- Main stylesheetresources/js/app.js- Main JavaScript bundle
vite.config.js:13-21)
- Listens on
0.0.0.0:5173for Docker compatibility - HMR configured for
localhost:5173 - Strict port mode enabled
- Ignores Laravel’s view cache directory
The
refresh: true option automatically reloads the browser when Blade templates change.Docker Node Service
The Node.js development server runs in a Docker container defined indocker-compose.yml:58-68:
Container Features
- Image: Node.js 22 Alpine (lightweight)
- Port Mapping:
5173:5173for Vite dev server - Volume: Separate
node_modulesvolume for performance - Auto-start: Automatically installs dependencies and starts dev server
NPM Scripts
Defined inpackage.json:5-8:
Script Details
| Script | Command | Purpose |
|---|---|---|
dev | vite | Start development server with HMR |
build | vite build | Build optimized assets for production |
JavaScript Structure
The JavaScript entry point is minimal and modular: resources/js/app.js (resources/js/app.js:1-2)
resources/js/bootstrap.js:1-5)
Global Objects
- window.axios: Configured Axios instance with CSRF protection
- Includes
X-Requested-Withheader for Laravel AJAX detection
Hot Module Replacement
Asset Compilation
Development Mode
Vite serves assets directly from source with fast HMR:Production Build
Generate optimized, versioned assets:- Minified JavaScript bundles
- Optimized CSS with purged unused styles
- Hashed filenames for cache busting
- Manifest file for Laravel integration
public/build/
Development Workflow
The complete development workflow uses Composer’sdev script (composer.json:43-46):
- PHP Server:
php artisan serve - Queue Worker:
php artisan queue:listen - Log Viewer:
php artisan pail - Vite Dev Server:
npm run dev
The
concurrently package provides colored output for each service, making it easy to monitor all processes.Troubleshooting
HMR Not Working
Issue: Changes don’t reflect in browser Solutions:- Verify Node container is running:
docker-compose ps node - Check Vite dev server is accessible:
curl http://localhost:5173 - Ensure
@vitedirective is in your Blade template - Clear browser cache
Port Already in Use
Issue:Port 5173 is already in use
Solutions:
- Stop other Vite instances:
docker-compose down - Kill process on port 5173:
lsof -ti:5173 | xargs kill - Change port in
vite.config.js(update bothportandhmr.port)
Node Modules Permission Errors
Issue: Permission denied innode_modules
Solutions:
- Rebuild Node container:
docker-compose up --build node - The container automatically fixes permissions on startup
- Ensure the named volume is properly mounted
Next Steps
Styling
Learn about the CSS architecture and Tailwind configuration
Deployment
Build and deploy assets for production