feat(pwa): telefona kurulum, uygulama kabuğu önbelleği, güncelleme bildirimi, çevrimdışı uyarısı
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+69
-1
@@ -2,10 +2,78 @@ 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()],
|
||||
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') },
|
||||
|
||||
Reference in New Issue
Block a user