import { defineConfig } from 'vite'; import { VitePWA } from 'vite-plugin-pwa'; // GitHub Pages / sub-path friendly: set BASE_PATH env at build time if needed. const base = process.env.BASE_PATH || '/'; export default defineConfig({ base, build: { target: 'es2020', sourcemap: true, }, plugins: [ VitePWA({ strategies: 'injectManifest', srcDir: 'src', filename: 'sw.js', registerType: 'prompt', injectManifest: { globPatterns: ['**/*.{js,css,html,svg,png,ico,json,webmanifest}'], // The bundled PokéAPI snapshot can be a few hundred KB. maximumFileSizeToCacheInBytes: 5 * 1024 * 1024, }, includeAssets: [ 'icon.svg', 'favicon.svg', 'apple-touch-icon.png', ], manifest: { name: 'Pocketdex', short_name: 'Pocketdex', description: 'An offline-first Pokédex, team builder and save-file tracker powered by PokéAPI.', start_url: './', scope: './', display: 'standalone', orientation: 'portrait', background_color: '#0b0b0c', theme_color: '#b3161a', categories: ['games', 'reference', 'utilities'], icons: [ { src: 'icon.svg', sizes: 'any', type: 'image/svg+xml', purpose: 'any' }, { src: 'pwa-192.png', sizes: '192x192', type: 'image/png', purpose: 'any' }, { src: 'pwa-512.png', sizes: '512x512', type: 'image/png', purpose: 'any' }, { src: 'pwa-maskable-512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable', }, ], shortcuts: [ { name: 'Team builder', short_name: 'Team', url: './#/team', icons: [{ src: 'pwa-192.png', sizes: '192x192' }], }, { name: 'Search', short_name: 'Search', url: './#/search', icons: [{ src: 'pwa-192.png', sizes: '192x192' }], }, { name: 'Type chart', short_name: 'Types', url: './#/types', icons: [{ src: 'pwa-192.png', sizes: '192x192' }], }, ], }, devOptions: { enabled: false, type: 'module', }, }), ], });