import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { viteStaticCopy } from "vite-plugin-static-copy";

const cesiumBuild = new URL("../../node_modules/cesium/Build/Cesium", import.meta.url).pathname;

export default defineConfig({
  plugins: [
    react(),
    viteStaticCopy({
      targets: ["Workers", "ThirdParty", "Assets", "Widgets"].map((directory) => ({
        src: `${cesiumBuild}/${directory}/**/*`,
        dest: `cesium/${directory}`,
        rename: { stripBase: 5 },
      })),
    }),
  ],
  define: {
    CESIUM_BASE_URL: JSON.stringify("/cesium/"),
  },
  build: {
    sourcemap: true,
  },
});
