test build2

This commit is contained in:
Ehab Hassan 2025-06-01 13:00:44 +03:00
parent 5f57ee1bcd
commit 84bc7fb1b1

View File

@ -1,47 +1,46 @@
#!/bin/bash echo "Starting build..."
set -e SOURCE=${BASH_SOURCE[0]}
echo "🧹 Cleaning build folders..." DIR_OF_THIS_SCRIPT="$( dirname "$SOURCE" )"
rm -rf public static/css ABS_DIR_OF_SCRIPT="$( realpath $DIR_OF_THIS_SCRIPT )"
echo "⬇️ Downloading TailwindCSS CLI..." # TODO: Check if current version is latest to avoid redundant installation
if [[ -f "tailwindcss.exe" ]]; then if [[ -f "tailwindcss" ]]
rm tailwindcss.exe then
rm tailwindcss
fi
# checks os and architecture for correct release
# https://stackoverflow.com/a/8597411
echo "Installing & building tailwind..."
ASSET="tailwindcss"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
ASSET="$ASSET-linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
ASSET="$ASSET-macos"
fi
if [[ "$(uname -m)" == "x86_64"* ]]; then
ASSET="$ASSET-x64"
elif [[ "$(uname -m)" == "arm64"* ]]; then
ASSET="$ASSET-arm64"
fi fi
ASSET="tailwindcss-windows-x64.exe"
curl -sLO "https://github.com/tailwindlabs/tailwindcss/releases/download/v3.4.17/${ASSET}" curl -sLO "https://github.com/tailwindlabs/tailwindcss/releases/download/v3.4.17/${ASSET}"
mv ${ASSET} tailwindcss.exe chmod +x $ASSET
chmod +x tailwindcss.exe mv $ASSET tailwindcss
# Ensure correct config
if [[ ! -f "tailwind.config.js" ]]; then # initialized and configures tailwind if not configured
echo "⚙️ Creating tailwind.config.js" echo "Initializing tailwind..."
echo "module.exports = { if [[ ! -f "tailwind.config.js" ]]
content: ['./templates/**/*.html'], then
theme: { extend: {} }, ./tailwindcss init
plugins: [], sed -i '' "s| content: \\[\\],| content: \\['./templates/**/*.html'\\],|g" tailwind.config.js
}" > tailwind.config.js
fi fi
# Build Tailwind CSS # compiles tailwind css for prod & builds project
echo "🎨 Building Tailwind CSS..." echo "Compiling tailwindcss and building zola project..."
./tailwindcss.exe -i css/index.css -o static/css/index.css --minify rm -rf public static/css
./tailwindcss -i css/index.css -o ./static/css/index.css --minify
if [[ ! -f "static/css/index.css" ]]; then zola --root $ABS_DIR_OF_SCRIPT build
echo "❌ Tailwind CSS not generated."
exit 1
fi
echo "✅ Tailwind CSS built at static/css/index.css"
# Build Zola site
echo "🏗️ Building site with Zola..."
zola build
# Final check
if [[ -f "public/css/index.css" ]]; then
echo "✅ CSS successfully copied to public/"
else
echo "❌ CSS NOT copied to public/. Check Zola static settings."
fi