// vite.config.ts
import path from "path";
import react from "file:///home/araneus/cwait/node_modules/@vitejs/plugin-react/dist/index.mjs";
import { visualizer } from "file:///home/araneus/cwait/node_modules/rollup-plugin-visualizer/dist/plugin/index.js";
import { loadEnv } from "file:///home/araneus/cwait/node_modules/vite/dist/node/index.js";
import { nodePolyfills } from "file:///home/araneus/cwait/node_modules/vite-plugin-node-polyfills/dist/index.js";
import wasm from "file:///home/araneus/cwait/node_modules/vite-plugin-wasm/exports/import.mjs";
import { defineConfig } from "file:///home/araneus/cwait/node_modules/vitest/dist/config.js";
var __vite_injected_original_dirname = "/home/araneus/cwait/packages/ui";
var vite_config_default = defineConfig(({ mode }) => {
  process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
  const base = process.env.VITE_BASENAME;
  return {
    base: base?.length != 0 ? base : "/",
    build: {
      sourcemap: true,
      chunkSizeWarningLimit: Infinity,
      target: "ESNEXT",
      minify: "esbuild",
      rollupOptions: {
        treeshake: true,
        output: {
          manualChunks: {
            react: ["react", "react-dom", "react-router-dom"],
            cms: ["contract.cm"]
          }
        },
        onwarn(warning, warn) {
          if (warning.code === "INVALID_ANNOTATION") {
            if (warning.message.includes("__PURE__")) {
              return;
            }
          }
          if (warning.message.includes('Use of eval in "../../node_modules/vm-browserify/index.js"')) {
            return;
          }
          warn(warning);
        }
      }
    },
    plugins: [
      react(),
      wasm(),
      nodePolyfills({
        include: ["process", "buffer", "vm", "crypto", "stream", "assert", "http", "https", "os", "url", "util"]
      }),
      visualizer({ open: false, filename: "bundle-visualization.html" })
    ],
    server: {
      port: 3e3,
      fs: {
        cachedChecks: false
      },
      proxy: {
        "/api/getTvl": {
          target: `${process.env.VITE_CWAP_API_URL}/cwap_cm/getTvl`,
          changeOrigin: true,
          rewrite: (path2) => {
            const result = path2.replace("/api/getTvl", "");
            const searchParams = new URLSearchParams({
              btcC1: process.env.VITE_L2_CONTRACT_ADDRESS_BASE_BTC ?? "",
              btcC2: process.env.VITE_L2_CONTRACT_ADDRESS_MAKER_BTC ?? "",
              ethC1: process.env.VITE_L2_CONTRACT_ADDRESS_BASE_ETH ?? "",
              ethC2: process.env.VITE_L2_CONTRACT_ADDRESS_MAKER_ETH ?? "",
              usdtEthC1: process.env.VITE_L2_CONTRACT_ADDRESS_BASE_USDT_ETH ?? "",
              usdtEthC2: process.env.VITE_L2_CONTRACT_ADDRESS_MAKER_USDT_ETH ?? "",
              usdtBnbC1: process.env.VITE_L2_CONTRACT_ADDRESS_BASE_USDT_BNB ?? "",
              usdtBnbC2: process.env.VITE_L2_CONTRACT_ADDRESS_MAKER_USDT_BNB ?? "",
              bnbC1: process.env.VITE_L2_CONTRACT_ADDRESS_BASE_BNB ?? "",
              bnbC2: process.env.VITE_L2_CONTRACT_ADDRESS_MAKER_BNB ?? ""
            });
            return result + "?" + searchParams.toString();
          }
        }
      }
    },
    test: {
      globals: true,
      environment: "jsdom",
      setupFiles: "./vitest.setup.ts",
      silent: true
    },
    define: {
      __MOCKS__: false
    },
    resolve: {
      alias: {
        process: "process/browser",
        buffer: "buffer",
        crypto: "crypto-browserify",
        stream: "stream-browserify",
        assert: "assert",
        http: "stream-http",
        https: "https-browserify",
        os: "os-browserify",
        url: "url",
        util: "util",
        "@": path.resolve(__vite_injected_original_dirname, "./src")
      }
    }
  };
});
export {
  vite_config_default as default
};
//# sourceMappingURL=data:application/json;base64,[encoded data, 8032 characters]
