import path from "path";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
import { sveltekit } from "@sveltejs/kit/vite";

export default defineConfig({
  plugins: [sveltekit(), tailwindcss()],
  resolve: {
    alias: { $lib: path.resolve("./src/lib"), "@": path.resolve("./src/lib") },
  },
  build: {
    rollupOptions: {
      external: ["@sexy/buttplug"],
    },
  },
  server: {
    port: 3000,
    proxy: {
      "/api": {
        rewrite: (path) => path.replace(/^\/api/, ""),
        target: "http://localhost:4000",
        changeOrigin: true,
        secure: false,
        ws: true,
      },
      "/buttplug": {
        rewrite: (path) => path.replace(/^\/buttplug/, ""),
        target: "http://localhost:8080",
        changeOrigin: true,
      },
    },
  },
});
