home
/
u941026986
/
domains
/
irole.co
/
public_html
/
scripts
➕ New
📤 Upload
✎ Editing:
build-production.sh
← Back
#!/bin/bash # Production Build Script for iRole Frontend # This script generates a production-optimized build of the frontend set -e # Exit on error echo "๐๏ธ Starting production build process..." # Get the root directory of the project ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT_DIR" || { echo "โ Cannot enter root directory" exit 1 } # Set production environment variables export NODE_ENV=production export VITE_API_URL="${VITE_API_URL:-https://irole.co/api}" echo "๐ฆ Environment:" echo " NODE_ENV: $NODE_ENV" echo " VITE_API_URL: $VITE_API_URL" # Check if node_modules exists, install if needed if [ ! -d "node_modules" ]; then echo "๐ฅ Installing dependencies..." npm install fi # Clean previous build if [ -d "build" ]; then echo "๐งน Cleaning previous build..." rm -rf build fi # Build the frontend echo "๐จ Building frontend for production..." npm run build # Verify build directory exists if [ ! -d "build" ]; then echo "โ Build directory was not created. Build failed!" exit 1 fi # Copy .htaccess to build directory if it exists if [ -f ".htaccess" ]; then echo "๐ Copying .htaccess to build directory..." cp .htaccess build/.htaccess echo "โ .htaccess copied successfully" else echo "โ ๏ธ Warning: .htaccess file not found in root directory" fi # Validate build output echo "๐ Validating build output..." if [ ! -f "build/index.html" ]; then echo "โ Build validation failed: index.html not found" exit 1 fi if [ ! -d "build/assets" ]; then echo "โ Build validation failed: assets directory not found" exit 1 fi # Count assets ASSET_COUNT=$(find build/assets -type f 2>/dev/null | wc -l | tr -d ' ') echo "๐ Build contains $ASSET_COUNT asset files" if [ "$ASSET_COUNT" -eq 0 ]; then echo "โ ๏ธ Warning: No asset files found in build" fi # Display build info BUILD_SIZE=$(du -sh build 2>/dev/null | cut -f1) echo "๐ฆ Build size: $BUILD_SIZE" echo "โ Production build completed successfully!" echo "๐ Build output: $ROOT_DIR/build"
💾 Save Changes
Cancel
📤 Upload File
×
Select File
Upload
Cancel
➕ Create New
×
Type
📄 File
📁 Folder
Name
Create
Cancel
✎ Rename Item
×
Current Name
New Name
Rename
Cancel
🔐 Change Permissions
×
Target File
Permission (e.g., 0755, 0644)
0755
0644
0777
Apply
Cancel