test
This commit is contained in:
parent
84bc7fb1b1
commit
19c71cec50
75
build.sh
75
build.sh
@ -1,46 +1,47 @@
|
||||
echo "Starting build..."
|
||||
#!/bin/bash
|
||||
|
||||
SOURCE=${BASH_SOURCE[0]}
|
||||
DIR_OF_THIS_SCRIPT="$( dirname "$SOURCE" )"
|
||||
ABS_DIR_OF_SCRIPT="$( realpath $DIR_OF_THIS_SCRIPT )"
|
||||
set -e
|
||||
echo "🧹 Cleaning build folders..."
|
||||
rm -rf public static/css
|
||||
|
||||
# TODO: Check if current version is latest to avoid redundant installation
|
||||
if [[ -f "tailwindcss" ]]
|
||||
then
|
||||
echo "⬇️ Downloading TailwindCSS CLI..."
|
||||
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"
|
||||
|
||||
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
|
||||
|
||||
ASSET="tailwindcss-linux-x64"
|
||||
curl -sLO "https://github.com/tailwindlabs/tailwindcss/releases/download/v3.4.17/${ASSET}"
|
||||
chmod +x $ASSET
|
||||
mv $ASSET tailwindcss
|
||||
mv ${ASSET} tailwindcss
|
||||
chmod +x tailwindcss
|
||||
|
||||
|
||||
# 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
|
||||
# Ensure correct config
|
||||
if [[ ! -f "tailwind.config.js" ]]; then
|
||||
echo "⚙️ Creating tailwind.config.js"
|
||||
echo "module.exports = {
|
||||
content: ['./templates/**/*.html'],
|
||||
theme: { extend: {} },
|
||||
plugins: [],
|
||||
}" > tailwind.config.js
|
||||
fi
|
||||
|
||||
# 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
|
||||
# Build Tailwind CSS
|
||||
echo "🎨 Building Tailwind CSS..."
|
||||
./tailwindcss -i css/index.css -o static/css/index.css --minify
|
||||
|
||||
if [[ ! -f "static/css/index.css" ]]; then
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user