Files
patriothacks/vite.config.ts

68 lines
2.3 KiB
TypeScript

import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import { VitePWA } from 'vite-plugin-pwa'
// https://vite.dev/config/
export default defineConfig({
server: {
// Local dev only: forwards the frontend's same-origin '/api/blob*'
// calls (install-QR cross-device sharing, todo 55) to the local blob
// API dev server (`node api/_lib/devServer.ts`, todo 56). At deploy
// time (todo 57) this proxy is unnecessary - Vercel serves `api/*.ts`
// functions from the exact same origin as the static frontend
// automatically, so '/api/blob' already resolves without a proxy.
proxy: {
'/api': {
target: `http://127.0.0.1:${process.env.BLOB_API_PORT ?? 3001}`,
changeOrigin: true,
},
},
},
plugins: [
react(),
// Workbox-based service worker: precaches the app shell (HTML/JS/CSS
// bundle) for offline load. The manifest below gives the app its
// installable Alipay/WeChat/Tuya mini-app-launcher identity.
VitePWA({
registerType: 'autoUpdate',
// Registration is done explicitly in src/main.tsx via the
// 'virtual:pwa-register' module, not auto-injected into index.html,
// so the shell root owns the registration call.
injectRegister: false,
manifest: {
name: 'The Commons',
short_name: 'The Commons',
description:
'The Commons - one shared identity, wallet, and event log across every civic mini-app in the Hollow.',
start_url: '/',
display: 'standalone',
// Alipay/WeChat/Tuya-inspired theme tokens: Alipay blue as the primary
// accent, a near-white app background matching the mini-app-launcher feel.
theme_color: '#1677FF',
background_color: '#F5F6F7',
icons: [
{
src: 'pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
},
{
src: 'pwa-maskable-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable',
},
],
},
workbox: {
globPatterns: ['**/*.{js,css,html,svg,png,ico}'],
},
}),
],
})