57 lines
1.7 KiB
Bash
Executable File
57 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
echo "Starting build..."
|
|
|
|
SOURCE=${BASH_SOURCE[0]}
|
|
DIR_OF_THIS_SCRIPT="$( dirname "$SOURCE" )"
|
|
ABS_DIR_OF_SCRIPT="$( realpath $DIR_OF_THIS_SCRIPT )"
|
|
|
|
# Determine platform
|
|
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
|
|
|
|
# Get the latest version from GitHub
|
|
LATEST_VERSION=$(curl -s https://api.github.com/repos/tailwindlabs/tailwindcss/releases/latest | grep '"tag_name":' | cut -d '"' -f 4)
|
|
|
|
# Get current version (if exists)
|
|
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 only if outdated or not installed
|
|
if [[ "$CURRENT_VERSION" != "$LATEST_VERSION" ]]; then
|
|
echo "Updating Tailwind to latest version..."
|
|
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 already up to date."
|
|
fi
|
|
|
|
# Initialize tailwind.config.js if not exists
|
|
if [[ ! -f "tailwind.config.js" ]]; then
|
|
echo "Initializing tailwind.config.js..."
|
|
./tailwindcss init
|
|
sed -i '' "s| content: \[\],| content: \['./templates/**/*.html'\],|g" tailwind.config.js
|
|
fi
|
|
|
|
# Build Tailwind CSS and Zola
|
|
echo "Compiling Tailwind CSS and building Zola site..."
|
|
rm -rf public static/css
|
|
./tailwindcss -i css/index.css -o static/css/index.css --minify
|
|
zola --root "$ABS_DIR_OF_SCRIPT" build
|