Files
sibedas/build-production.sh
2025-06-13 13:36:27 +00:00

43 lines
1.3 KiB
Bash

#!/bin/bash
# Production build script dengan optimasi memory
# Untuk server dengan resource terbatas
echo "🔨 Starting production build with memory optimization..."
# Set Node.js memory limit (adjust sesuai RAM server)
# Untuk server dengan banyak file, gunakan memory yang lebih besar
export NODE_OPTIONS="--max-old-space-size=2048 --max-semi-space-size=1024"
# Use production vite config
export NODE_ENV=production
# Clean previous build
echo "🧹 Cleaning previous build..."
rm -rf public/build/*
# Build with limited resources
echo "📦 Building assets with memory optimization..."
# Option 1: Build with custom config
vite build --config vite.config.production.js
# Option 2: Alternative - build in chunks (uncomment if needed)
# echo "Building CSS files first..."
# vite build --config vite.config.production.js --mode css-only
#
# echo "Building JS files..."
# vite build --config vite.config.production.js --mode js-only
if [ $? -eq 0 ]; then
echo "✅ Build completed successfully!"
echo "📊 Build summary:"
du -sh public/build/*
else
echo "❌ Build failed!"
echo "💡 Try these solutions:"
echo " 1. Increase server memory"
echo " 2. Build locally and upload files"
echo " 3. Use swap memory (temporary solution)"
exit 1
fi