fooder-app/vite.config.ts
2026-04-03 22:13:20 +02:00

60 lines
1.9 KiB
TypeScript

import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
import tailwindcss from '@tailwindcss/vite';
export default defineConfig({
server: {
proxy: {
'/api': {
target: process.env.VITE_API_URL ?? 'http://localhost:8000',
changeOrigin: true
}
}
},
plugins: [
tailwindcss(),
sveltekit(),
VitePWA({
registerType: 'autoUpdate',
manifestFilename: 'manifest.json',
includeAssets: ['icons/icon.svg', 'icons/apple-touch-icon-180x180.png'],
devOptions: { enabled: true },
manifest: {
name: 'Fooder',
short_name: 'Fooder',
description: 'Simple calorie and macro tracker',
theme_color: '#16a34a',
background_color: '#09090b',
display: 'standalone',
orientation: 'portrait',
start_url: '/diary/today',
scope: '/',
id: '/',
categories: ['health', 'food'],
icons: [
{ src: '/icons/pwa-64x64.png', sizes: '64x64', type: 'image/png' },
{ src: '/icons/pwa-192x192.png', sizes: '192x192', type: 'image/png' },
{ src: '/icons/pwa-512x512.png', sizes: '512x512', type: 'image/png' },
{ src: '/icons/maskable-icon-512x512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' }
]
},
workbox: {
navigateFallback: '/index.html',
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
runtimeCaching: [
{
// Cache same-origin API responses (NetworkFirst: try network, fall back to cache)
urlPattern: ({ url }) => url.pathname.startsWith('/api/'),
handler: 'NetworkFirst',
options: {
cacheName: 'api-cache',
networkTimeoutSeconds: 5,
cacheableResponse: { statuses: [200] }
}
}
]
}
})
]
});