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

export default defineConfig({
  plugins: [
    vue(),
    VitePWA({
      registerType: 'autoUpdate',
      // filename в корне - Android требует SW в scope приложения
      includeAssets: ['favicon.ico', 'icon_phone/apple-touch-icon.png'],
      manifest: {
        id: '/',
        name: 'TaskBoard',
        short_name: 'TaskBoard',
        description: 'Task management application',
        theme_color: '#111113',
        background_color: '#111113',
        display: 'standalone',
        orientation: 'portrait',
        scope: '/',
        start_url: '/',
        icons: [
          {
            src: 'icon_phone/pwa-192x192.png',
            sizes: '192x192',
            type: 'image/png'
          },
          {
            src: 'icon_phone/pwa-512x512.png',
            sizes: '512x512',
            type: 'image/png'
          },
          {
            src: 'icon_phone/pwa-512x512.png',
            sizes: '512x512',
            type: 'image/png',
            purpose: 'maskable'
          }
        ]
      },
      workbox: {
        // Полностью отключаем кеширование - как в браузере
        globPatterns: [],
        runtimeCaching: []
      }
    })
  ],
  server: {
    host: '0.0.0.0',
    port: 5173
  }
})
