jevhooks.git / tools / build-web.sh
1#!/usr/bin/env bash

What wrangler dev and wrangler deploy run before they serve or upload (web/wrangler.toml, [build]): the link preview's card, then the Worker. So a Worker cannot go out whose own tags point at a picture that was never made.

tools/build-web.sh        (mise run web:build)

The card is drawn by the site's own code (web/src/bin/card.rs prints an SVG) and made a PNG by resvg, because the apps that show link previews do not draw SVG.

10set -euo pipefail
11cd "$(dirname "$0")/.."
12for tool in cargo resvg worker-build; do
13  command -v "$tool" >/dev/null || { echo "build-web: $tool is not installed (mise install)" >&2; exit 1; }
14done
16out=web/public/preview
17mkdir -p "$out"
18cargo run --quiet --manifest-path web/Cargo.toml --bin card > "$out/card.svg"
19resvg "$out/card.svg" "$out/card.png"
20rm "$out/card.svg"
21[ -s "$out/card.png" ] || { echo "build-web: the card was not drawn" >&2; exit 1; }
22
23cd web
24exec worker-build --release