← back to Dw Install Docs

build.sh

24 lines

#!/usr/bin/env bash
# Render every sources/*.html into dist/*.pdf on DW letterhead via headless Chrome.
# Usage: ./build.sh   (bash 3.2 compatible — macOS default)
set -euo pipefail
cd "$(dirname "$0")"

CHROME="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
[ -x "$CHROME" ] || { echo "Google Chrome not found at expected path"; exit 1; }

mkdir -p dist

shopt -s nullglob  # empty sources/ → skip loop instead of rendering a literal "sources/*.html"
for html in sources/*.html; do
  base="$(basename "$html" .html)"
  case "$base" in
    vegan-leather-wall-hangguide) out="Vegan-Leather-Wall-HangGuide.pdf" ;;
    pigskin-vinyl-spec)           out="Pigskin-Vinyl-Spec-Sheet.pdf" ;;
    *)                            out="$base.pdf" ;;
  esac
  "$CHROME" --headless --disable-gpu --no-pdf-header-footer \
    --print-to-pdf="dist/$out" "file://$(pwd)/$html" 2>/dev/null
  echo "rendered dist/$out"
done