Files
pikasTech-HWLAB/web/hwlab-cloud-web/vite.config.ts
T
root 15fbd59f83 Merge remote-tracking branch 'origin/v0.3' into feat/2625-workbench-temporal
# Conflicts:
#	web/hwlab-cloud-web/vite.config.ts
2026-07-17 08:07:20 +02:00

67 lines
2.2 KiB
TypeScript

import { Agent } from "node:http";
import { fileURLToPath, URL } from "node:url";
import vue from "@vitejs/plugin-vue";
import { defineConfig, loadEnv } from "vite";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const nativeApiUrl = String(process.env.WORKBENCH_NATIVE_API_URL ?? env.WORKBENCH_NATIVE_API_URL ?? "").trim();
const nativeCaseRunEnabled = (process.env.HWLAB_CASERUN_NATIVE_TEST ?? env.HWLAB_CASERUN_NATIVE_TEST) === "1";
const nativeCaseRunTarget = process.env.HWLAB_CASERUN_NATIVE_URL ?? env.HWLAB_CASERUN_NATIVE_URL ?? "http://127.0.0.1:4316";
const nativeCaseRunAgent = new Agent({ keepAlive: true });
if (nativeApiUrl && nativeCaseRunEnabled) {
throw new Error("Workbench and CaseRun native modes cannot share one Vite server");
}
return {
plugins: [vue()],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url))
}
},
server: {
host: env.WORKBENCH_WEB_HOST || "127.0.0.1",
port: Number(env.WORKBENCH_WEB_PORT || 5173),
strictPort: true,
watch: nativeCaseRunEnabled || env.WORKBENCH_VITE_USE_POLLING === "1"
? { usePolling: true, interval: nativeCaseRunEnabled ? 300 : 500 }
: undefined,
proxy: nativeCaseRunEnabled
? {
"/auth": {
target: nativeCaseRunTarget,
changeOrigin: false,
agent: nativeCaseRunAgent
},
"/v1/caserun": {
target: nativeCaseRunTarget,
changeOrigin: false,
agent: nativeCaseRunAgent
}
}
: nativeApiUrl
? {
"/v1": { target: nativeApiUrl, changeOrigin: false },
"/auth": { target: nativeApiUrl, changeOrigin: false },
"/health": { target: nativeApiUrl, changeOrigin: false }
}
: undefined
},
build: {
outDir: "dist",
emptyOutDir: true,
sourcemap: false,
rollupOptions: {
output: {
entryFileNames: "app.js",
chunkFileNames: "assets/[name].js",
assetFileNames: "assets/[name][extname]"
}
}
}
};
});