// @ts-check
import { defineConfig, mergeConfig } from "vite";
import { baseConfig } from "./vite.config.mjs";
import {
  apiServerBaseURL,
  apiServerPort,
} from "./configs/vars.mjs";

const config = defineConfig(async (configEnv) => {
  /**
   * @type {import("vite").UserConfig}
   */
  const devConfig = {
    server: {
      host: "0.0.0.0",
      port: 3450,
      strictPort: true,
      proxy: {
        "/api": `${apiServerBaseURL}:${apiServerPort}`
      },
      allowedHosts: [
        "web",
      ],
    },
  };
  const resolvedBase = await baseConfig(configEnv);
  const finalConfig = mergeConfig(resolvedBase, devConfig);

  return finalConfig;
});

export default config;
