feat: PWA + full web app — service worker, routing, mobile responsive
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Ryan Lancaster
2026-03-18 17:42:34 -04:00
parent 758fa37c2a
commit 9cc677ce68
9 changed files with 4445 additions and 45 deletions

View File

@@ -1,13 +1,65 @@
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import { VitePWA } from 'vite-plugin-pwa'
// Use relative base so built assets load correctly from filesystem/Electron
// Ports are defined in the root .env file (PORT_FRONTEND_DEV, PORT_BACKEND)
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, '../', '')
const isElectron = process.env.ELECTRON === '1'
return {
base: './',
plugins: [react()],
base: isElectron ? './' : '/',
plugins: [
react(),
// PWA disabled for Electron builds
!isElectron && VitePWA({
registerType: 'autoUpdate',
injectRegister: 'auto',
includeAssets: ['icons/icon.svg'],
manifest: {
name: 'Project Hub',
short_name: 'Project Hub',
description: 'All your projects, one place',
theme_color: '#090910',
background_color: '#090910',
display: 'standalone',
start_url: '/',
scope: '/',
orientation: 'any',
icons: [
{
src: '/icons/icon.svg',
sizes: 'any',
type: 'image/svg+xml',
purpose: 'any',
},
{
src: '/icons/icon.svg',
sizes: 'any',
type: 'image/svg+xml',
purpose: 'maskable',
},
],
},
workbox: {
globPatterns: ['**/*.{js,css,html,svg,png,ico,woff2}'],
runtimeCaching: [
{
urlPattern: /^\/api\//,
handler: 'NetworkFirst',
options: {
cacheName: 'api-cache',
networkTimeoutSeconds: 5,
expiration: { maxEntries: 200, maxAgeSeconds: 86400 },
cacheableResponse: { statuses: [0, 200] },
},
},
],
},
devOptions: { enabled: false },
}),
].filter(Boolean),
server: {
host: env.VITE_DEV_HOST || '0.0.0.0',
port: parseInt(env.PORT_FRONTEND_DEV) || 5173,