#!/bin/bash
# Minify index.html from src/ to production version
# Usage: ./minify.sh
set -e
SRC_FILE="$(dirname "$0")/src/index.html"
OUT_FILE="$(dirname "$0")/index.html"
TEMP_FILE="${OUT_FILE}.tmp"
if [ ! -f "$SRC_FILE" ]; then
echo "❌ Source file not found: $SRC_FILE"
exit 1
fi
echo "🔨 Minifying HTML..."
echo " Input: $SRC_FILE"
echo " Output: $OUT_FILE"
perl -e "
use strict;
use warnings;
open(my \$fh, '<', '$SRC_FILE') or die \$!;
my \$content = do { local \$/; <\$fh> };
close(\$fh);
# Remove HTML comments
\$content =~ s///gs;
# Compress CSS (remove spaces and comments)
\$content =~ s/(