This commit is contained in:
2024-11-23 05:15:57 +03:00
parent ea1bd3e542
commit 0d7807d297
5 changed files with 10 additions and 60 deletions

View File

@@ -1,57 +1,10 @@
echo "Starting build..."
#!/bin/bash
set -ex
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 "Download 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
curl -sLO "https://github.com/tailwindlabs/tailwindcss/releases/latest/download/${ASSET}"
# Check if the download size is greater than 20MB
if [[ $(stat -c%s "$ASSET") -lt 20000000 ]]; then
echo "Error: Downloaded file size is less than 20MB, download not ok."
echo "Download url was:$ASSET"
rm "$ASSET"
exit 1
fi
chmod +x $ASSET
mv $ASSET tailwindcss
export BASE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${BASE}"
# 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
fi
source env.sh
# compiles tailwind css for prod & builds project
echo "Compiling tailwindcss and building zola project..."
rm -rf public static/css
./tailwindcss -i css/index.css -o ./static/css/index.css --minify
zola --root $ABS_DIR_OF_SCRIPT build
open public/index.html
zola serve