Vapora/assets/web/minify.sh
Jesús Pérez 8f6a884f6e docs: Update README and CHANGELOG with web assets optimization
- Document web assets restructuring with minification pipeline
  * 32% compression (26KB → 18KB)
  * Bilingual support (EN/ES) preserved
  * Automated minify.sh script for version sync
  * Complete README.md guide with examples

- Add web assets structure to project directory layout in README
  - New assets/web/ section with source and production versions
  - Reference to minification script and documentation

- Include Just recipes documentation for local development
  - Show `just help` commands for discovering available recipes
  - Document 50+ recipes for build, test, and CI operations

- Update CHANGELOG with infrastructure improvements
  - Web assets optimization (32% compression)
  - Just recipes CI/CD system (50+ commands)
  - Code quality improvements and bug fixes
  - Markdown linting compliance achieved
  - All tests passing (55/55 in vapora-backend)

- Add build and test results to unreleased changes section
  - Clean compilation with 0 warnings in vapora-backend
  - 55 tests passing
  - Clippy compliance achieved
2026-01-11 20:12:56 +00:00

88 lines
1.9 KiB
Bash
Executable File

#!/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/(<style[^>]*>)(.*?)(<\/style>)/
my \$before = \$1;
my \$style = \$2;
my \$after = \$3;
\$style =~ s{\/\*.*?\*\/}{}gs;
\$style =~ s{\s+}{ }gs;
\$style =~ s{\s*([{}:;,>+~])\s*}{\$1}gs;
\$before . \$style . \$after;
/gies;
# Compress JavaScript (remove comments and extra spaces)
\$content =~ s/(<script[^>]*>)(.*?)(<\/script>)/
my \$before = \$1;
my \$script = \$2;
my \$after = \$3;
\$script =~ s{\/\/.*\$}{}gm;
\$script =~ s{\s+}{ }gs;
\$script =~ s{\s*([{}();,])\s*}{\$1}gs;
\$before . \$script . \$after;
/gies;
# Remove whitespace between tags
\$content =~ s/>\s+</></gs;
# Compress general whitespace
\$content =~ s/\s+/ /gs;
# Trim
\$content =~ s/^\s+|\s+\$//g;
open(my \$out, '>', '$TEMP_FILE') or die \$!;
print \$out \$content;
close(\$out);
" || {
echo "❌ Minification failed"
rm -f "$TEMP_FILE"
exit 1
}
mv "$TEMP_FILE" "$OUT_FILE"
# Show statistics
original=$(wc -c < "$SRC_FILE")
minified=$(wc -c < "$OUT_FILE")
saved=$((original - minified))
percent=$((saved * 100 / original))
echo ""
echo "✅ Minification complete!"
echo ""
echo "📊 Compression statistics:"
printf " Original: %6d bytes\n" "$original"
printf " Minified: %6d bytes\n" "$minified"
printf " Saved: %6d bytes (%d%%)\n" "$saved" "$percent"
echo ""
echo "$OUT_FILE is ready for production"