60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
VitePWA({
|
|
registerType: 'autoUpdate',
|
|
includeAssets: ['icons/icon-192.png', 'icons/icon-512.png'],
|
|
manifest: {
|
|
name: 'KtoCo - Wydatki wspólne',
|
|
short_name: 'KtoCo',
|
|
description: 'Dzielenie wydatków dla par i współlokatorów',
|
|
theme_color: '#4f46e5',
|
|
background_color: '#ffffff',
|
|
display: 'standalone',
|
|
start_url: '/',
|
|
icons: [
|
|
{ src: 'icons/icon-192.png', sizes: '192x192', type: 'image/png' },
|
|
{ src: 'icons/icon-512.png', sizes: '512x512', type: 'image/png' },
|
|
{ src: 'icons/icon-512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' },
|
|
],
|
|
},
|
|
workbox: {
|
|
navigateFallbackDenylist: [/^\/api\//],
|
|
clientsClaim: true,
|
|
skipWaiting: true,
|
|
runtimeCaching: [
|
|
{
|
|
urlPattern: ({ url }) => url.pathname.startsWith('/api/') && url.pathname !== '/api/expenses',
|
|
handler: 'NetworkFirst',
|
|
method: 'GET',
|
|
options: {
|
|
cacheName: 'api-get-cache',
|
|
networkTimeoutSeconds: 4,
|
|
expiration: { maxEntries: 100, maxAgeSeconds: 7 * 24 * 60 * 60 },
|
|
},
|
|
},
|
|
{
|
|
urlPattern: ({ url }) => url.pathname === '/api/expenses',
|
|
handler: 'NetworkFirst',
|
|
method: 'GET',
|
|
options: { cacheName: 'api-expenses-cache', networkTimeoutSeconds: 4 },
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
],
|
|
server: {
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:3000',
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
|
},
|
|
},
|
|
},
|
|
});
|