import { resolve } from "node:path"; import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; // https://vite.dev/config/ export default defineConfig({ plugins: [react()], build: { rollupOptions: { input: { main: resolve(__dirname, "index.html"), worldshaperStudio: resolve(__dirname, "worldshaper-studio.html"), worldshaperHeightViewer: resolve(__dirname, "worldshaper-height-viewer.html"), }, output: { manualChunks(id) { const normalizedId = id.replace(/\\/g, "/"); if (normalizedId.includes("node_modules")) { if (normalizedId.includes("/pixi.js/")) { return "vendor-pixi"; } if (normalizedId.includes("/react/") || normalizedId.includes("/react-dom/")) { return "vendor-react"; } return "vendor-misc"; } if (!normalizedId.includes("/src/worldshaperStudio/")) { return undefined; } if ( normalizedId.includes("tileArtEditorWindowController") || normalizedId.includes("entityEditorWindowController") || normalizedId.includes("engineOverrideWindowController") || normalizedId.includes("statusLogWindowController") || normalizedId.includes("changelogSplashWindowController") || normalizedId.includes("toolWindowController") || normalizedId.includes("worldOverviewWindowController") ) { return "map-editor-windows"; } if (normalizedId.includes("pixiTileStageController")) { return "map-editor-pixi"; } if ( normalizedId.includes("renderController") || normalizedId.includes("overlayRenderer") ) { return "map-editor-render"; } if ( normalizedId.includes("interactionController") || normalizedId.includes("sidebarController") || normalizedId.includes("npcController") || normalizedId.includes("historyController") || normalizedId.includes("historyStateStore") || normalizedId.includes("importController") || normalizedId.includes("persistenceController") || normalizedId.includes("graphicsDocumentHelpers") ) { return "map-editor-core"; } return undefined; }, }, }, }, server: { host: true, port: 4170, proxy: { "/api": { target: "http://localhost:5180", changeOrigin: true, }, }, }, preview: { host: true, port: 4170, }, });