# Deployment Guide

## Production Deployment Steps

### 1. Build Vite Assets (REQUIRED)

Before deploying to production, you **MUST** build the Vite assets:

```bash
npm install
npm run build
```

This will generate the `public/build/manifest.json` file and all compiled assets that Laravel needs in production.

### 2. Deploy Build Directory

Ensure the `public/build` directory is deployed to your production server. The `.gitignore` file includes `!/public/build` which means this directory should be committed to git.

### 3. Production Server Setup

On your production server, after pulling the latest code:

```bash
# Install dependencies (if not already done)
composer install --no-dev --optimize-autoloader
npm install --production=false  # Need dev dependencies for build
npm run build                   # Build assets for production

# Clear Laravel caches
php artisan config:clear
php artisan cache:clear
php artisan view:clear
php artisan route:clear
```

### 4. Verify Build Files

After deployment, verify that these files exist:
- `public/build/manifest.json`
- `public/build/assets/*.js`
- `public/build/assets/*.css`

### 5. Troubleshooting

If you see the error: `Vite manifest not found at: /path/to/public/build/manifest.json`

**Solution:**
1. SSH into your production server
2. Navigate to your project directory
3. Run: `npm run build`
4. Verify the `public/build/manifest.json` file exists
5. Clear Laravel caches: `php artisan config:clear && php artisan view:clear`

### 6. CI/CD Integration

If using CI/CD, add these steps to your deployment pipeline:

```yaml
# Example GitLab CI/CD
build:
  script:
    - npm install
    - npm run build
  artifacts:
    paths:
      - public/build/
```

### 7. Environment Variables

Ensure your production `.env` file has:
- `APP_ENV=production`
- `APP_DEBUG=false`
- `APP_URL=https://your-domain.com`

## Quick Fix for Current Issue

If you're currently experiencing the manifest error:

```bash
# On production server
cd /home/giantand/hkam.giantandro.com
npm install
npm run build
php artisan config:clear
php artisan view:clear
```

