import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; import { fileURLToPath } from "url"; import { dirname, resolve } from "path"; import tailwindcss from "@tailwindcss/vite"; import { VitePWA } from "vite-plugin-pwa"; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); // https://vite.dev/config/ export default defineConfig({ plugins: [ react(), tailwindcss(), VitePWA({ registerType: 'autoUpdate', includeAssets: ['favicon.ico', 'spotizerr.svg', '*.svg'], injectRegister: 'auto', manifest: { name: 'Spotizerr', short_name: 'Spotizerr', description: 'Music downloader and manager for Spotify content', theme_color: '#1e293b', background_color: '#0f172a', display: 'standalone', scope: '/', start_url: '/', lang: 'en', orientation: 'portrait-primary', categories: ['music', 'entertainment', 'utilities'], icons: [ { src: 'pwa-192x192.png', sizes: '192x192', type: 'image/png' }, { src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png' }, { src: 'pwa-192x192.png', sizes: '192x192', type: 'image/png', purpose: 'maskable' }, { src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' }, { src: 'apple-touch-icon-180x180.png', sizes: '180x180', type: 'image/png' } ] }, workbox: { globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'], navigateFallback: 'index.html', navigateFallbackDenylist: [/^\/_/, /\/[^/?]+\.[^/]+$/], runtimeCaching: [ { urlPattern: /^https:\/\/api\./i, handler: 'NetworkFirst', options: { cacheName: 'api-cache', expiration: { maxEntries: 100, maxAgeSeconds: 60 * 60 * 24 // 24 hours } } }, { urlPattern: /\.(?:png|jpg|jpeg|svg|gif|webp)$/, handler: 'CacheFirst', options: { cacheName: 'images-cache', expiration: { maxEntries: 500, maxAgeSeconds: 60 * 60 * 24 * 30 // 30 days } } } ] }, devOptions: { enabled: true, type: 'module' } }) ], resolve: { alias: { "@": resolve(__dirname, "./src"), }, }, server: { proxy: { "/api": { target: "http://localhost:7171", changeOrigin: true, }, }, }, });