2025-11-12 17:50:44 +01:00
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
|
import react from '@vitejs/plugin-react'
|
2025-11-19 20:59:26 +01:00
|
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
2025-11-12 17:50:44 +01:00
|
|
|
|
2025-11-15 14:12:51 +01:00
|
|
|
// Parse allowed hosts from environment variable
|
|
|
|
|
const getAllowedHosts = () => {
|
|
|
|
|
const hosts = process.env.VITE_ALLOWED_HOSTS;
|
|
|
|
|
|
|
|
|
|
// If set to 'all', allow all hosts
|
|
|
|
|
if (hosts === 'all') {
|
|
|
|
|
return 'all';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If set, parse comma-separated list
|
|
|
|
|
if (hosts) {
|
|
|
|
|
return hosts.split(',').map(h => h.trim());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Default: localhost only
|
|
|
|
|
return ['localhost'];
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-12 17:50:44 +01:00
|
|
|
// https://vite.dev/config/
|
|
|
|
|
export default defineConfig({
|
2025-11-19 20:59:26 +01:00
|
|
|
plugins: [
|
|
|
|
|
react(),
|
|
|
|
|
VitePWA({
|
|
|
|
|
registerType: 'autoUpdate',
|
|
|
|
|
includeAssets: ['favicon.ico', 'robots.txt', 'apple-touch-icon.png'],
|
|
|
|
|
manifest: {
|
|
|
|
|
name: 'spotlight.cam - Dance Event Video Exchange',
|
|
|
|
|
short_name: 'spotlight',
|
|
|
|
|
description: 'P2P video exchange platform for dance event participants',
|
|
|
|
|
theme_color: '#6366f1',
|
|
|
|
|
background_color: '#ffffff',
|
|
|
|
|
display: 'standalone',
|
|
|
|
|
orientation: 'portrait',
|
|
|
|
|
scope: '/',
|
|
|
|
|
start_url: '/',
|
|
|
|
|
icons: [
|
|
|
|
|
{
|
|
|
|
|
src: '/icons/icon-192x192.png',
|
|
|
|
|
sizes: '192x192',
|
|
|
|
|
type: 'image/png',
|
|
|
|
|
purpose: 'any maskable',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
src: '/icons/icon-512x512.png',
|
|
|
|
|
sizes: '512x512',
|
|
|
|
|
type: 'image/png',
|
|
|
|
|
purpose: 'any maskable',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
src: '/icons/apple-touch-icon.png',
|
|
|
|
|
sizes: '180x180',
|
|
|
|
|
type: 'image/png',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
workbox: {
|
|
|
|
|
// Cache only static assets (no API caching)
|
|
|
|
|
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
|
|
|
|
|
runtimeCaching: [
|
|
|
|
|
{
|
|
|
|
|
// Cache images from ui-avatars.com
|
|
|
|
|
urlPattern: /^https:\/\/ui-avatars\.com\/.*/i,
|
|
|
|
|
handler: 'CacheFirst',
|
|
|
|
|
options: {
|
|
|
|
|
cacheName: 'avatar-images',
|
|
|
|
|
expiration: {
|
|
|
|
|
maxEntries: 100,
|
|
|
|
|
maxAgeSeconds: 60 * 60 * 24 * 7, // 7 days
|
|
|
|
|
},
|
|
|
|
|
cacheableResponse: {
|
|
|
|
|
statuses: [0, 200],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
navigateFallback: null, // Disable offline fallback (app requires internet)
|
|
|
|
|
},
|
|
|
|
|
devOptions: {
|
|
|
|
|
enabled: false, // Disable in dev to avoid conflicts
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
],
|
2025-11-12 17:50:44 +01:00
|
|
|
server: {
|
|
|
|
|
host: '0.0.0.0',
|
|
|
|
|
port: 5173,
|
2025-11-15 14:12:51 +01:00
|
|
|
allowedHosts: getAllowedHosts(),
|
2025-11-12 17:50:44 +01:00
|
|
|
watch: {
|
|
|
|
|
usePolling: true,
|
|
|
|
|
},
|
|
|
|
|
hmr: {
|
|
|
|
|
clientPort: 8080,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|