add last version of tailwind
This commit is contained in:
parent
6948c25978
commit
3c56b93d1f
58
build.sh
58
build.sh
@ -1,20 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Starting build..."
|
||||
|
||||
SOURCE=${BASH_SOURCE[0]}
|
||||
DIR_OF_THIS_SCRIPT="$( dirname "$SOURCE" )"
|
||||
ABS_DIR_OF_SCRIPT="$( realpath $DIR_OF_THIS_SCRIPT )"
|
||||
|
||||
# TODO: Check if current version is latest to avoid redundant installation
|
||||
if [[ -f "tailwindcss" ]]
|
||||
then
|
||||
rm tailwindcss
|
||||
fi
|
||||
|
||||
# checks os and architecture for correct release
|
||||
# https://stackoverflow.com/a/8597411
|
||||
echo "Installing & building tailwind..."
|
||||
# Determine platform
|
||||
ASSET="tailwindcss"
|
||||
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
ASSET="$ASSET-linux"
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
@ -26,21 +19,38 @@ elif [[ "$(uname -m)" == "arm64"* ]]; then
|
||||
ASSET="$ASSET-arm64"
|
||||
fi
|
||||
|
||||
curl -sLO "https://github.com/tailwindlabs/tailwindcss/releases/download/v3.4.17/${ASSET}"
|
||||
chmod +x $ASSET
|
||||
mv $ASSET tailwindcss
|
||||
# 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)
|
||||
|
||||
|
||||
# initialized and configures tailwind if not configured
|
||||
echo "Initializing tailwind..."
|
||||
if [[ ! -f "tailwind.config.js" ]]
|
||||
then
|
||||
./tailwindcss init
|
||||
sed -i '' "s| content: \\[\\],| content: \\['./templates/**/*.html'\\],|g" tailwind.config.js
|
||||
# Get current version (if exists)
|
||||
CURRENT_VERSION=""
|
||||
if [[ -f "./tailwindcss" ]]; then
|
||||
CURRENT_VERSION=$(./tailwindcss -v | awk '{print $2}')
|
||||
fi
|
||||
|
||||
# compiles tailwind css for prod & builds project
|
||||
echo "Compiling tailwindcss and building zola project..."
|
||||
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
|
||||
./tailwindcss -i css/index.css -o static/css/index.css --minify
|
||||
zola --root "$ABS_DIR_OF_SCRIPT" build
|
||||
|
Loading…
Reference in New Issue
Block a user