import { sveltekit } from '@sveltejs/kit/vite';
import { imagetools } from 'vite-imagetools';
import { SvelteKitPWA } from '@vite-pwa/sveltekit';
import { defineConfig } from 'vite';

export default defineConfig({
	plugins: [
		sveltekit(),
		imagetools(),
		SvelteKitPWA({
			registerType: 'autoUpdate',
			injectRegister: false,
			manifest: false,
			workbox: {
				globPatterns: ['**/*.{js,css,html,svg,woff2,webp,avif,png,ico}'],
				navigateFallback: '/offline/index.html',
				navigateFallbackDenylist: [/\.(?:pdf|mp4|webm|mp3)$/i],
				globIgnores: ['**/assets/*.pdf', '**/archives/*.pdf'],
				maximumFileSizeToCacheInBytes: 3 * 1024 * 1024,
				cleanupOutdatedCaches: true,
				clientsClaim: true,
				skipWaiting: true
			}
		})
	]
});
