Files
cv-site/Makefile
T
juanatsap 95de841e14 feat: Add CSS bundling with Lightning CSS for production optimization
- Add Lightning CSS integration for CSS bundling and minification
- Create Makefile targets: css-dev, css-prod, css-watch, css-clean
- Implement conditional CSS loading based on GO_ENV (dev=modular, prod=bundled)
- Add IsProduction template variable for environment-aware rendering
- Keep print.css separate with media="print" for PDF export
- Add static/dist/ to .gitignore (generated bundles)
- Fix Go template syntax in _cv-header.css
- Remove redundant font @import in _typography.css

Performance gains:
- 27 HTTP requests → 1 (96% reduction)
- 188KB → 86KB CSS (54% reduction)
- ~15KB gzip network transfer

Documentation:
- Update 12-CSS-ARCHITECTURE.md with bundling section
- Add Phase 9 to 2-MODERN-WEB-TECHNIQUES.md
- Add css-bundling.test.mjs Playwright test (8/8 pass)
2025-11-30 12:32:46 +00:00

85 lines
2.5 KiB
Makefile

.PHONY: test test-all test-unit test-integration lint build dev run clean css-dev css-prod css-watch css-clean
# Default: Run unit tests only (fast, no Chrome needed)
test: test-unit
# Run unit tests only (CI-safe, no Chrome)
test-unit:
@echo "🧪 Running unit tests..."
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
# Run ALL tests including PDF/Chrome integration tests
test-all:
@echo "🧪 Running ALL tests (including integration tests)..."
go test -v -race -tags=integration -coverprofile=coverage.txt -covermode=atomic ./...
# Run integration tests only
test-integration:
@echo "🧪 Running integration tests only..."
go test -v -race -tags=integration ./internal/handlers -run PDF
# Run linter
lint:
@echo "🔍 Running golangci-lint..."
golangci-lint run
# Build binary
build:
@echo "🔨 Building..."
go build -v -o cv-server .
# Run in development mode with hot reload
dev:
@echo "🚀 Starting development server with hot reload..."
GO_ENV=development TEMPLATE_HOT_RELOAD=true go run main.go
# Run in production mode
run:
@echo "🚀 Starting server..."
go run main.go
# Clean build artifacts
clean: css-clean
@echo "🧹 Cleaning build artifacts..."
rm -f cv-server coverage.txt coverage-report.txt benchmark.txt
# Run all checks (lint + unit tests)
check: lint test-unit
@echo "✅ All checks passed!"
# Run everything (lint + all tests + build)
all: lint test-all css-prod build
@echo "✅ Everything passed!"
# ============================================================================
# CSS Build Targets (Lightning CSS)
# ============================================================================
# Bundle CSS for development (readable, with source maps)
css-dev:
@echo "🎨 Bundling CSS for development..."
@mkdir -p static/dist
lightningcss --bundle static/css/main.css -o static/dist/bundle.css
@echo "✅ Created static/dist/bundle.css"
# Bundle and minify CSS for production
css-prod:
@echo "🎨 Bundling and minifying CSS for production..."
@mkdir -p static/dist
lightningcss --bundle --minify static/css/main.css -o static/dist/bundle.min.css
@echo "✅ Created static/dist/bundle.min.css ($$(wc -c < static/dist/bundle.min.css | tr -d ' ') bytes)"
# Watch CSS files for changes (development)
css-watch:
@echo "👀 Watching CSS files for changes..."
@while true; do \
$(MAKE) css-dev; \
fswatch -1 -r static/css; \
done
# Clean generated CSS files
css-clean:
@echo "🧹 Cleaning generated CSS..."
rm -rf static/dist
@echo "✅ Cleaned static/dist/"