fix(branding): wrap generator to clean up staged brand source
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>
This commit is contained in:
parent
eebb566323
commit
88ab432629
2 changed files with 20 additions and 1 deletions
|
|
@ -5,7 +5,7 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "electron/main.cjs",
|
"main": "electron/main.cjs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"generate-pwa-assets": "pwa-assets-generator",
|
"generate-pwa-assets": "node scripts/generate-pwa-assets.mjs",
|
||||||
"dev": "vite --host",
|
"dev": "vite --host",
|
||||||
"build": "vue-tsc -b && vite build",
|
"build": "vue-tsc -b && vite build",
|
||||||
"preview": "vite preview --host",
|
"preview": "vite preview --host",
|
||||||
|
|
|
||||||
19
scripts/generate-pwa-assets.mjs
Normal file
19
scripts/generate-pwa-assets.mjs
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/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)
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue