pwa-assets.config.ts stages the brand logo in public/icons/.brand-source.* so the CLI (which emits next to its source) writes alongside it. Without cleanup, the full-resolution 1024+ source ends up in dist/icons/ on every build and is publicly served at /icons/.brand-source.png. scripts/generate-pwa-assets.mjs runs the CLI, then removes the staged source. Wire it through the `generate-pwa-assets` pnpm script. Part of aiolabs/webapp#95. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
19 lines
837 B
JavaScript
19 lines
837 B
JavaScript
#!/usr/bin/env node
|
|
// Wraps pwa-assets-generator and removes the staged brand source after
|
|
// generation. pwa-assets.config.ts copies $BRAND_DIR/logo.{svg,png}
|
|
// into public/icons/.brand-source.* because the CLI emits next to the
|
|
// source. Without this cleanup the full-resolution source ships in
|
|
// dist/icons/ and is publicly served.
|
|
import { spawnSync } from 'node:child_process'
|
|
import { existsSync, rmSync } from 'node:fs'
|
|
import { resolve } from 'node:path'
|
|
|
|
const cli = resolve('node_modules/.bin/pwa-assets-generator')
|
|
const { status } = spawnSync(cli, process.argv.slice(2), { stdio: 'inherit' })
|
|
if (status !== 0) process.exit(status ?? 1)
|
|
|
|
const stagingDir = resolve('public/icons')
|
|
for (const ext of ['svg', 'png']) {
|
|
const staged = resolve(stagingDir, `.brand-source.${ext}`)
|
|
if (existsSync(staged)) rmSync(staged)
|
|
}
|