Build dex spritesheet assets in the deploy script

Replaces the esbuild invocation that ran out of the smogon.com checkout:
the deploy script now stamps the webp, rewrites the css urls, and writes
the hashed css plus the suffix file that updateminisprites.sh ships to
/smog2/dex/spritesheet_css_suffix.txt. updateminisprites.sh no longer
depends on ~/smogon/smogon.com/run, esbuild, python, or zopfli/brotli
(css precompression dropped; to be handled separately). Minification is
also dropped (machine-generated css, ~same size compressed).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Christopher Monsanto
2026-08-15 23:47:22 -04:00
parent f772bf1357
commit 997668ec2e
2 changed files with 22 additions and 10 deletions

View File

@@ -147,6 +147,23 @@ for (const f of list("build/item-minisprites-trimmed")) {
itemspritecopy(f, {dir: "xyitems"});
}
// Dex spritesheet assets: hash-stamped css + webp, plus the css suffix file
// shipped to /smog2/dex/spritesheet_css_suffix.txt (read by dex render).
{
const wh = hash("build/smogon/spritesheet.webp");
copy("build/smogon/spritesheet.webp", `assets/spritesheet-${wh}.webp`);
const src = read("build/smogon/spritesheet.css");
const css = src.replaceAll('url("./spritesheet.webp")', `url("./spritesheet-${wh}.webp")`);
if (css === src) {
throw new Error("spritesheet.css: no webp urls rewritten");
}
// Suffix from source content: the rewritten css is a pure function of
// (css, webp), so this changes exactly when the served bytes change.
const ch = hash("build/smogon/spritesheet.css", "build/smogon/spritesheet.webp");
write(`assets/spritesheet-${ch}.css`, css);
write("spritesheet_css_suffix.txt", `-${ch}\n`);
}
let h = hash(...list("build/smogon/minisprites"));
for (const f of list("build/smogon/minisprites")) {
newspritecopy(f, {dir: "minisprites/" + h});

View File

@@ -5,19 +5,14 @@ set -ex
cd ~/smogon/sprites
pnpm build
rm -rf deploy/smogon
node tools/deploy/index.ts run smogon.deploy.js -o deploy/smogon
# Update dex
cd ~/smogon/smogon.com/run
rm -rf ~/smogon/sprites/build/smogon/spritesheetoutput
pnpm exec esbuild ~/smogon/sprites/build/smogon/spritesheet.css --asset-names='[name]-[hash]' --entry-names='[name]-[hash]' --loader:.webp=copy --minify --allow-overwrite --bundle --outdir=/home/monsanto/smogon/sprites/build/smogon/spritesheetoutput
zopfli ~/smogon/sprites/build/smogon/spritesheetoutput/spritesheet-*.css
brotli -9 ~/smogon/sprites/build/smogon/spritesheetoutput/spritesheet-*.css
rsync ~/smogon/sprites/build/smogon/spritesheetoutput/* smogon:/smog2/sprites/assets
python -c 'import re; import pathlib; print(re.match(r"spritesheet(.*)\.css", str(list(pathlib.Path("/home/monsanto/smogon/sprites/build/smogon/spritesheetoutput/.").glob("spritesheet-*.css"))[0].name)).group(1))' | ssh smogon 'cat > /smog2/dex/spritesheet_css_suffix.txt'
rsync deploy/smogon/assets/* smogon:/smog2/sprites/assets
ssh smogon 'cat > /smog2/dex/spritesheet_css_suffix.txt' < deploy/smogon/spritesheet_css_suffix.txt
ssh smogon 'systemctl reload dex'
# Update forum minisprites
cd /home/monsanto/smogon/sprites
rm -rf deploy/smogon
node tools/deploy/index.ts run smogon.deploy.js -o deploy/smogon
rsync -a deploy/smogon/forumsprites/ smogon:/smog2/forumsprites/minisprites
rsync -a deploy/smogon/xyicons/ smogon:/smog2/sprites/xyicons