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

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    tailwindcss(),
    //BasicSSL(),
    VitePWA({
      registerType: "autoUpdate",
      workbox: {
        globPatterns: ["**/*"],
        maximumFileSizeToCacheInBytes: 5 * 1024 ** 2, // 5MB
      },
      includeAssets: ["**/*"],
      manifest: {
        name: "YaBL app",
        short_name: "YaBL",
        description: "Yet another Book Library",
        theme_color: "#feba4b",
        start_url: "/pwa",
        icons: [
          {
            src: "favicon.png",
            sizes: "192x192",
            type: "image/png",
          },
          {
            src: "favicon.png",
            sizes: "512x512",
            type: "image/png",
          },
        ],
      },
    }),
  ],
  server: {
    proxy: {
      "/api": "http://localhost:8080",
    },
  },
  preview: {
    proxy: {
      "/api": "http://localhost:8080",
    },
    https: false,
  },
});
