import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { VitePWA } from 'vite-plugin-pwa'

export default defineConfig({
  base: '/hk-planner/',
  plugins: [
    react(),
    VitePWA({
      registerType: 'autoUpdate',
      manifest: {
        name: 'HK Planner',
        short_name: 'HK Planner',
        start_url: '/hk-planner/',
        scope: '/hk-planner/',
        display: 'standalone',
        theme_color: '#2d6a4f',
        background_color: '#2d6a4f',
        icons: [
          { src: '/hk-planner/icons/icon-192.png', sizes: '192x192', type: 'image/png' },
          { src: '/hk-planner/icons/icon-512.png', sizes: '512x512', type: 'image/png' },
        ],
      },
      workbox: {
        navigateFallback: '/hk-planner/index.html',
        navigateFallbackDenylist: [/\/api\//],
        globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
      },
    }),
  ],
})
