#!/bin/bash # Scriberr Build Script # This script builds the React frontend and embeds it in the Go binary set -e # Exit on any error echo "๐Ÿš€ Starting Scriberr build process..." # Step 1: Clean up old files echo "๐Ÿงน Cleaning up old build files..." rm -f scriberr rm -rf internal/web/dist cd web/frontend # Remove old build output and copied files rm -rf dist/ rm -rf assets/ 2>/dev/null || true echo "โœ… Old files cleaned" # Step 2: Build React frontend echo "๐Ÿ“ฆ Building React frontend..." npm run build echo "โœ… React frontend built successfully" # Step 3: Copy dist files to internal/web for embedding echo "๐Ÿ“ Copying dist files for Go embedding..." cd ../.. rm -rf internal/web/dist cp -r web/frontend/dist internal/web/ echo "โœ… Dist files copied to internal/web" # Step 4: Clean Go build cache and rebuild binary echo "๐Ÿ”จ Building Go binary with embedded static files..." go clean -cache go build -o scriberr cmd/server/main.go echo "โœ… Go binary built successfully" echo "๐ŸŽ‰ Build complete! Run './scriberr' to start the server"