import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import vueDevTools from "vite-plugin-vue-devtools";
import tailwindcss from "@tailwindcss/postcss";
import autoprefixer from "autoprefixer";
import Components from "unplugin-vue-components/vite";
import RekaResolver from "reka-ui/resolver";

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue({
      template: {
        compilerOptions: {
          // 将所有 wokwi- 开头的标签视为自定义元素
          isCustomElement: (tag) => tag.startsWith("wokwi-"),
        },
      },
    }),
    vueJsx(),
    vueDevTools(),
    Components({
      dts: true,
      resolvers: [
        RekaResolver(),

        // RekaResolver({
        //   prefix: '' // use the prefix option to add Prefix to the imported components
        // })
      ],
    }),
  ],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  css: {
    postcss: {
      plugins: [tailwindcss(), autoprefixer()],
    },
  },
  build: {
    outDir: "wwwroot",
    emptyOutDir: true, // also necessary
  },
  server: {
    proxy: {
      "/swagger": {
        target: "http://localhost:5000",
        changeOrigin: true,
      },
    },
    port: 5173,
  },
});
