import { svelte } from '@sveltejs/vite-plugin-svelte'; import { defineConfig } from 'vite'; import { VitePWA } from 'vite-plugin-pwa'; export default defineConfig({ server: { host: '0.0.0.0', }, plugins: [ svelte(), VitePWA({ // Never `autoUpdate`: a worker swap mid-day reloads the page under the // user's hands. The app decides when to apply an update (see // src/lib/updates.svelte.js) and only offers it while no day is running. registerType: 'prompt', pwaAssets: { image: 'public/icon.svg', }, manifest: { name: 'TimeLog — suivi des heures', short_name: 'TimeLog', description: "Suivi des heures de chantier hors ligne, avec récapitulatif de la dernière journée.", lang: 'fr', dir: 'ltr', start_url: '/', scope: '/', display: 'standalone', orientation: 'portrait', background_color: '#ffffff', theme_color: '#0047b3', categories: ['productivity', 'utilities'], }, workbox: { // The whole app is a handful of files; precache it all so a cold start // offline is identical to a warm one. // // `webmanifest` is deliberately NOT in this list: the plugin injects its // own manifest entry, and a glob that also matches it produces two // precache entries for the same URL with different revisions. Workbox // rejects conflicting entries, the install handler throws, and nothing // gets cached at all — the app silently stops working offline. globPatterns: ['**/*.{js,css,html,svg,png,ico}'], cleanupOutdatedCaches: true, clientsClaim: false, }, }), ], test: { include: ['src/**/*.test.js'], environment: 'node', }, });