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

export default defineConfig({
  plugins: [
    vue(),
    VitePWA({
      registerType: "autoUpdate",
      includeAssets: ["favicon.ico", "logo.png", "logo192.png", "logo512.png"],
      manifest: {
        name: "萌芽SSH",
        short_name: "萌芽SSH",
        description: "柔和渐变风格的 Web SSH 连接面板，支持多窗口终端。",
        start_url: "/",
        display: "standalone",
        theme_color: "#0f172a",
        background_color: "#020617",
        icons: [
          {
            src: "logo192.png",
            sizes: "192x192",
            type: "image/png",
          },
          {
            src: "logo512.png",
            sizes: "512x512",
            type: "image/png",
            purpose: "maskable",
          },
        ],
      },
    }),
  ],
  server: {
    host: true,
    port: 5173,
    proxy: {
      // HTTP API：/api/... → http://localhost:8080/api/...
      "/api": {
        target: "http://localhost:8080",
        changeOrigin: true,
        // WebSocket 升级（ws:// / wss://）
        ws: true,
      },
    },
  },
});
