Files
pikasTech-HWLAB/web/hwlab-cloud-web/vite.config.ts
T
2026-07-17 03:11:45 +02:00

52 lines
1.4 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 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 });
return {
plugins: [vue()],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url))
}
},
server: nativeCaseRunEnabled ? {
watch: {
usePolling: true,
interval: 300
},
proxy: {
"/auth": {
target: nativeCaseRunTarget,
changeOrigin: false,
agent: nativeCaseRunAgent
},
"/v1/caserun": {
target: nativeCaseRunTarget,
changeOrigin: false,
agent: nativeCaseRunAgent
}
}
} : undefined,
build: {
outDir: "dist",
emptyOutDir: true,
sourcemap: false,
rollupOptions: {
output: {
entryFileNames: "app.js",
chunkFileNames: "assets/[name].js",
assetFileNames: "assets/[name][extname]"
}
}
}
};
});