import { defineConfig } from 'vite'
import { resolve, dirname } from 'path'
import { fileURLToPath } from 'url'
import vue from '@vitejs/plugin-vue'
import { VitePWA } from 'vite-plugin-pwa'
import websocketPlugin from './vite-plugin-websocket.js'

const __dirname = dirname(fileURLToPath(import.meta.url))

// Configurazione principale di Vite
export default defineConfig({
  base: '/',
  build: {
    rollupOptions: {
      input: {
        main: resolve(__dirname, 'index.html'),
        controller: resolve(__dirname, 'controller.html'),
      },
    },
  },
  plugins: [
    vue(),
    websocketPlugin(),
    VitePWA({
      registerType: 'autoUpdate',
      manifest: {
        name: "app_segnap",
        short_name: "segnap",
        description: "Segnapunti standalone.",
        background_color: "#eee",
        theme_color: '#ffffff',
        display: "fullscreen",
        orientation: "landscape",
        icons: [
          {
            src: 'segnap-192x192.png',
            sizes: '192x192',
            type: 'image/png'
          },
          {
            src: 'segnap-512x512.png',
            sizes: '512x512',
            type: 'image/png'
          }
        ]
      }
    })
  ],
  server: {
    host: '0.0.0.0',
    port: 5173,
  },
})
