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