Files
kakeibo/frontend/vite.config.ts
T

90 lines
3.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import path from 'node:path'
import tailwindcss from '@tailwindcss/vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import { VitePWA } from 'vite-plugin-pwa'
// https://vite.dev/config/
export default defineConfig({
plugins: [
react(),
tailwindcss(),
// PWA: telefona "Ana ekrana ekle" ile kurulum + uygulama kabuğunun önbelleği.
// Veri (/api) ASLA önbelleğe alınmaz: ekranda her zaman sunucudaki güncel veri olur.
VitePWA({
// Yeni sürüm kendiliğinden devreye girmez; kullanıcıya "Yenile" sorulur (lib/pwa.tsx)
registerType: 'prompt',
injectRegister: false,
manifest: {
name: 'Kakeibo — Ev Defteri',
short_name: 'Kakeibo',
description: 'Kakeibo yöntemiyle hane bazlı ev bütçesi ve harcama defteri',
lang: 'tr',
dir: 'ltr',
start_url: '/',
scope: '/',
display: 'standalone',
orientation: 'portrait',
background_color: '#ffffff',
theme_color: '#ffffff',
categories: ['finance', 'productivity'],
icons: [
{ src: '/icon-192.png', sizes: '192x192', type: 'image/png', purpose: 'any' },
{ src: '/icon-512.png', sizes: '512x512', type: 'image/png', purpose: 'any' },
{
src: '/icon-maskable-512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable',
},
],
// Ana ekran ikonuna uzun basınca kısayollar
shortcuts: [
{
name: 'Harcama ekle',
short_name: 'Harcama',
url: '/defter',
icons: [{ src: '/icon-192.png', sizes: '192x192' }],
},
{ name: 'Panel', url: '/', icons: [{ src: '/icon-192.png', sizes: '192x192' }] },
],
},
workbox: {
globPatterns: ['**/*.{js,css,html,svg,png,ico,woff2}'],
// Nadiren gerekenler önceden indirilmez (ilk kurulum küçük kalsın): Excel okuyucu,
// Türkçede kullanılmayan font alt kümeleri. Gerekirse açılınca önbelleğe girer (aşağıda).
globIgnores: [
'**/xlsx-*.js',
'**/inter-{vietnamese,greek,greek-ext,cyrillic,cyrillic-ext}-*',
],
// Tek sayfa uygulama: gezinmeler index.html'e; /api asla
navigateFallback: '/index.html',
navigateFallbackDenylist: [/^\/api\//],
cleanupOutdatedCaches: true,
runtimeCaching: [
{
// Hash'li dosya adı → içerik değişmez; önceden alınmamışsa ilk kullanımda saklanır
urlPattern: ({ url }) => url.pathname.startsWith('/assets/'),
handler: 'CacheFirst',
options: { cacheName: 'kakeibo-assets', expiration: { maxEntries: 60 } },
},
],
},
// Geliştirmede service worker yok (hot reload ile çakışmasın)
devOptions: { enabled: false },
}),
],
resolve: {
// "@/lib/format" → src/lib/format
alias: { '@': path.resolve(import.meta.dirname, './src') },
},
server: {
port: 5173,
strictPort: true,
// /api istekleri Rust backend'e yönlenir → aynı origin, CORS gerekmez
proxy: {
'/api': 'http://localhost:8080',
},
},
})