import { fileURLToPath, URL } from "node:url"; import { loadEnv, defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; // https://vite.dev/config/ export default defineConfig((mode) => { const env = loadEnv(mode.mode, process.cwd()); return { base: process.env.NODE_ENV === 'production' ? '/cockpit/' : '/', plugins: [vue()], resolve: { alias: { "@": fileURLToPath(new URL("./src", import.meta.url)), }, }, server: { proxy: { [env.VITE_BASE_API]: { target: env.VITE_PROXY_PATH, ws: false, changeOrigin: true, rewrite: (path) => path.replace(new RegExp("^" + env.VITE_BASE_API), ""), }, }, }, css: { preprocessorOptions: { less: { additionalData: '@import "@/global.less";', }, }, }, }; });