Compare commits

...

2 Commits

Author SHA1 Message Date
5f57ee1bcd test build 2025-06-01 12:09:01 +03:00
d7d238dfb0 test build.sh 2025-06-01 12:07:10 +03:00

108
build.sh
View File

@ -1,91 +1,47 @@
#!/bin/bash #!/bin/bash
echo "🚀 Starting build..." set -e
echo "🧹 Cleaning build folders..."
rm -rf public static/css
SOURCE=${BASH_SOURCE[0]} echo "⬇️ Downloading TailwindCSS CLI..."
DIR_OF_THIS_SCRIPT="$( dirname "$SOURCE" )" if [[ -f "tailwindcss.exe" ]]; then
ABS_DIR_OF_SCRIPT="$( realpath "$DIR_OF_THIS_SCRIPT" )" rm tailwindcss.exe
# Detect platform for Tailwind binary
ASSET="tailwindcss"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
ASSET="$ASSET-linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
ASSET="$ASSET-macos"
fi fi
if [[ "$(uname -m)" == "x86_64"* ]]; then ASSET="tailwindcss-windows-x64.exe"
ASSET="$ASSET-x64" curl -sLO "https://github.com/tailwindlabs/tailwindcss/releases/download/v3.4.17/${ASSET}"
elif [[ "$(uname -m)" == "arm64"* ]]; then mv ${ASSET} tailwindcss.exe
ASSET="$ASSET-arm64" chmod +x tailwindcss.exe
fi
# Get latest Tailwind version from GitHub # Ensure correct config
LATEST_VERSION=$(curl -s https://api.github.com/repos/tailwindlabs/tailwindcss/releases/latest | grep '"tag_name":' | cut -d '"' -f 4)
# Check current version
CURRENT_VERSION=""
if [[ -f "./tailwindcss" ]]; then
CURRENT_VERSION=$(./tailwindcss -v | awk '{print $2}')
fi
echo "Current Tailwind version: $CURRENT_VERSION"
echo "Latest Tailwind version: $LATEST_VERSION"
# Download Tailwind binary if needed
if [[ "$CURRENT_VERSION" != "$LATEST_VERSION" ]]; then
echo "⬇️ Downloading latest Tailwind..."
rm -f tailwindcss
curl -sLO "https://github.com/tailwindlabs/tailwindcss/releases/download/${LATEST_VERSION}/${ASSET}"
chmod +x $ASSET
mv $ASSET tailwindcss
else
echo "✅ Tailwind is up to date."
fi
# Initialize Tailwind config if needed
if [[ ! -f "tailwind.config.js" ]]; then if [[ ! -f "tailwind.config.js" ]]; then
echo "🛠 Initializing Tailwind config..." echo "⚙️ Creating tailwind.config.js"
./tailwindcss init echo "module.exports = {
sed -i.bak "s| content: \[\],| content: \['./templates/**/*.html'\],|g" tailwind.config.js content: ['./templates/**/*.html'],
theme: { extend: {} },
plugins: [],
}" > tailwind.config.js
fi fi
# Ensure static/css exists # Build Tailwind CSS
mkdir -p static/css echo "🎨 Building Tailwind CSS..."
./tailwindcss.exe -i css/index.css -o static/css/index.css --minify
# Clean previous build if [[ ! -f "static/css/index.css" ]]; then
rm -rf public echo "❌ Tailwind CSS not generated."
exit 1
# Compile Tailwind
echo "🧵 Building Tailwind CSS..."
# Create a backup of the original CSS file
cp css/index.css css/index.css.bak
# Generate the CSS file with Tailwind
./tailwindcss -i css/index.css -o static/css/index.css --minify
# Check if the generated CSS file is empty or very small
if [ ! -s static/css/index.css ] || [ $(wc -c < static/css/index.css) -lt 1000 ]; then
echo "⚠️ Warning: Generated CSS file is empty or very small. Using backup CSS file."
# If Tailwind fails to generate a proper CSS file, use a pre-generated one
cp css/index.css.bak static/css/index.css
fi fi
# Print the size of the generated CSS file echo "✅ Tailwind CSS built at static/css/index.css"
echo "📏 Generated CSS file size: $(du -h static/css/index.css | cut -f1)"
# Build Zola site # Build Zola site
echo "🏗 Running Zola..." echo "🏗️ Building site with Zola..."
zola --root "$ABS_DIR_OF_SCRIPT" build zola build
# Ensure CSS is in the public directory # Final check
echo "📋 Ensuring CSS is in public directory..." if [[ -f "public/css/index.css" ]]; then
mkdir -p public/css echo "✅ CSS successfully copied to public/"
cp static/css/index.css public/css/ else
echo "❌ CSS NOT copied to public/. Check Zola static settings."
# Also copy to the root of public for fallback fi
echo "📋 Also copying CSS to root of public for fallback..."
cp static/css/index.css public/index.css
echo "✅ Build complete. Check public/ folder."