feat(branding): drive PWA manifest from brand.json

vite-branding.ts now loads brand.json into a typed `brand` object and
exports a `brandManifestName()` helper. Schema:

  { name (required), shortName?, themeColor?, backgroundColor? }

Default brand.json drops themeColor/backgroundColor — they're optional
overrides; per-app accents (wallet yellow, chat green, …) keep working
via `?? '<existing>'` fallbacks in each standalone's vite config.

events: manifest.name/short_name driven by brand. VITE_APP_NAME env
override stays (Phase 2 server-deploy migration still in flight) and,
when set, overrides both name and short_name to preserve pre-#95
behavior. cfaun's VITE_APP_NAME=Bouge keeps working unchanged.

hub (vite.config.ts): brand.name flows into %VITE_APP_NAME% Hub title.

7 other standalones (wallet, chat, market, forum, tasks, restaurant,
libra): only theme_color/background_color get brand overrides. Their
manifest.name/short_name stay hardcoded so multi-PWA home-screen
labels remain differentiated ("Wallet", "Chat", …) rather than all
collapsing to the brand short_name.

Verified default build: events manifest name=AIO; wallet keeps
"Wallet — Lightning" + #eab308 accent.
Verified VITE_APP_NAME=Sortir override: events name+short_name=Sortir.

Part of aiolabs/webapp#95.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Padreug 2026-06-09 23:11:30 +02:00
commit ce5a1a6a56
11 changed files with 74 additions and 32 deletions

View file

@ -5,7 +5,7 @@ import { defineConfig, type Plugin } from 'vite'
import { VitePWA } from 'vite-plugin-pwa'
import { ViteImageOptimizer } from 'vite-plugin-image-optimizer'
import { visualizer } from 'rollup-plugin-visualizer'
import { brandAlias } from './vite-branding'
import { brand, brandAlias, brandManifestName } from './vite-branding'
/**
* Plugin to rewrite dev server requests to events.html
@ -42,10 +42,12 @@ function eventsHtmlPlugin(): Plugin {
* VITE_BASE_PATH=/events/ app.ariege.io/events/ (shared auth)
* (default: /) bouge.ariege.io (standalone subdomain)
*
* Set VITE_APP_NAME to brand the standalone (PWA name, HTML title, console
* logs). cfaun overrides to "Bouge" via NixOS. Defaults to "Events".
* Brand name resolves from brand.json under $BRAND_DIR (see
* vite-branding.ts and aiolabs/webapp#95). VITE_APP_NAME remains an
* env override during the Phase 2 server-deploy migration; drop the
* env path once all hosts have moved to BRAND_DIR.
*/
const APP_NAME = process.env.VITE_APP_NAME || 'Events'
const APP_NAME = process.env.VITE_APP_NAME ?? brandManifestName()
// Surface the resolved value back into env so Vite's HTML %VITE_APP_NAME%
// substitution picks up the fallback when nothing was explicitly set.
process.env.VITE_APP_NAME = APP_NAME
@ -86,10 +88,12 @@ export default defineConfig(({ mode }) => ({
],
manifest: {
name: APP_NAME,
short_name: APP_NAME,
// VITE_APP_NAME, when set, overrides both name and short_name to
// preserve the pre-#95 behavior. Otherwise brand.shortName drives.
short_name: process.env.VITE_APP_NAME ?? brand.shortName ?? APP_NAME,
description: 'Discover events near you',
theme_color: '#1f2937',
background_color: '#ffffff',
theme_color: brand.themeColor ?? '#1f2937',
background_color: brand.backgroundColor ?? '#ffffff',
display: 'standalone',
orientation: 'portrait-primary',
start_url: process.env.VITE_BASE_PATH || '/',