Makefile
This commit is contained in:
@ -22,6 +22,10 @@ while [[ $# -gt 0 ]]; do
|
||||
esac
|
||||
done
|
||||
|
||||
# Get the directory where this script is located
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
echo "Script directory: $SCRIPT_DIR"
|
||||
|
||||
OS=$(uname -s)
|
||||
ARCH=$(uname -m)
|
||||
|
||||
@ -46,7 +50,7 @@ case $ARCH in
|
||||
"x86_64")
|
||||
ARCH="x64"
|
||||
;;
|
||||
"arm64")
|
||||
"arm64"|"aarch64")
|
||||
ARCH="arm64"
|
||||
;;
|
||||
*)
|
||||
@ -54,28 +58,34 @@ case $ARCH in
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
# Construct the binary file name
|
||||
BINARY="./tw/${OS}-${ARCH}"
|
||||
|
||||
echo "Detected OS: $OS"
|
||||
echo "Detected Architecture: $ARCH"
|
||||
|
||||
# Use tw directory in script location
|
||||
BINARY="${SCRIPT_DIR}/tw/${OS}-${ARCH}"
|
||||
if [ "$OS" = "windows" ]; then
|
||||
BINARY="${BINARY}.exe"
|
||||
else
|
||||
# Set execute permissions on the binary
|
||||
chmod +x $BINARY
|
||||
fi
|
||||
|
||||
echo "Looking for binary at: $BINARY"
|
||||
|
||||
# Check if binary exists
|
||||
if [ ! -f "$BINARY" ]; then
|
||||
echo "Binary not found: $BINARY"
|
||||
echo "Contents of ${SCRIPT_DIR}/tw/:"
|
||||
ls -la "${SCRIPT_DIR}/tw/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make binary executable
|
||||
chmod +x "$BINARY"
|
||||
|
||||
echo "Using binary: $BINARY"
|
||||
echo "Extensions: $EXTENSIONS"
|
||||
echo "Directory: $DIRECTORY"
|
||||
echo "Output Directory: $OUTPUT_DIR"
|
||||
|
||||
# Set default values if not provided
|
||||
OUTPUT_DIR="${OUTPUT_DIR:-../../public/css}"
|
||||
DIRECTORY="${DIRECTORY:-.}"
|
||||
|
||||
if [[ -z "$EXTENSIONS" ]]; then
|
||||
echo "No extensions provided."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Initialize an array for name conditions
|
||||
name_conditions=()
|
||||
|
||||
@ -90,12 +100,10 @@ INCLUDE_FILES=$(find "$DIRECTORY" -type f \( "${name_conditions[@]}" \))
|
||||
|
||||
echo "Files found: $INCLUDE_FILES"
|
||||
|
||||
# Optionally, remove leading './' if necessary
|
||||
INCLUDE_FILES=$(echo "$INCLUDE_FILES" | sed 's|^\./||')
|
||||
|
||||
INCLUDE_FILES_ARRAY=$(echo "$INCLUDE_FILES" | awk '{printf "\"%s\",", $0}' | sed 's/,$//')
|
||||
|
||||
# Generate Tailwind config
|
||||
# Generate Tailwind config in script directory
|
||||
CONFIG_FILE="${SCRIPT_DIR}/tailwind.config.js"
|
||||
echo "module.exports = {
|
||||
content: [$INCLUDE_FILES_ARRAY],
|
||||
theme: {
|
||||
@ -105,13 +113,10 @@ echo "module.exports = {
|
||||
themes: [\"night\"],
|
||||
},
|
||||
plugins: [require('daisyui'), require('@tailwindcss/typography')],
|
||||
}" > tailwind.config.js
|
||||
|
||||
# Delete original CSS file if it exists
|
||||
rm -f "${OUTPUT_DIR}/styles.css"
|
||||
}" > "$CONFIG_FILE"
|
||||
|
||||
# Run the binary with the generated config
|
||||
$BINARY build -i ./base.css -c tailwind.config.js -o "${OUTPUT_DIR}/styles.css" --minify
|
||||
"$BINARY" build -i "${SCRIPT_DIR}/base.css" -c "$CONFIG_FILE" -o "${OUTPUT_DIR}/styles.css" --minify
|
||||
|
||||
# Wait for all background processes to finish
|
||||
wait
|
||||
wait
|
||||
|
Reference in New Issue
Block a user