Adds a web app manifest, Workbox service worker (via vite-plugin-pwa), and placeholder icons so the app can be installed to a home screen / app window. App shell is precached for offline load; API and upload requests stay network-only so city data and photos are never served stale. Desktop browser access is unaffected. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
VitePWA({
|
|
registerType: 'autoUpdate',
|
|
injectRegister: false,
|
|
devOptions: {
|
|
enabled: false,
|
|
},
|
|
manifest: {
|
|
name: 'CityTracker',
|
|
short_name: 'CityTracker',
|
|
description: "Track cities you've visited or plan to visit on a map.",
|
|
start_url: '/',
|
|
scope: '/',
|
|
display: 'standalone',
|
|
theme_color: '#1971c2',
|
|
background_color: '#f7f7f5',
|
|
icons: [
|
|
{
|
|
src: '/pwa-192x192.png',
|
|
sizes: '192x192',
|
|
type: 'image/png',
|
|
},
|
|
{
|
|
src: '/pwa-512x512.png',
|
|
sizes: '512x512',
|
|
type: 'image/png',
|
|
},
|
|
{
|
|
src: '/maskable-512x512.png',
|
|
sizes: '512x512',
|
|
type: 'image/png',
|
|
purpose: 'maskable',
|
|
},
|
|
],
|
|
},
|
|
workbox: {
|
|
// /api and /uploads are intentionally left uncached so city data and
|
|
// photos always come from the network, never a stale service worker cache.
|
|
runtimeCaching: [
|
|
{
|
|
urlPattern: /^https:\/\/[abc]\.tile\.openstreetmap\.org\/.*/,
|
|
handler: 'CacheFirst',
|
|
options: {
|
|
cacheName: 'osm-tiles',
|
|
expiration: {
|
|
maxEntries: 500,
|
|
maxAgeSeconds: 60 * 60 * 24 * 7,
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
],
|
|
server: {
|
|
port: 5173,
|
|
proxy: {
|
|
'/api': 'http://localhost:3000',
|
|
'/uploads': 'http://localhost:3000',
|
|
},
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
},
|
|
});
|