Files

58 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2026-08-01 10:28:39 +05:30
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
// Empty means same-origin. A separate deployment sets VITE_MASKANX_API_URL.
const apiBaseUrl = (
env.VITE_MASKANX_API_URL ??
env.BASE_URL ??
""
).replace(/\/+$/, "");
const proxyTarget =
env.VITE_MASKANX_PROXY_TARGET || "http://127.0.0.1:8088";
return {
define: {
BASE_URL: JSON.stringify(apiBaseUrl),
TOKEN: JSON.stringify(env.VITE_MASKANX_API_TOKEN || env.TOKEN || ""),
MOBILE: false,
},
plugins: [react()],
css: {
modules: {
localsConvention: "camelCase",
generateScopedName: "[name]__[local]__[hash:base64:5]",
},
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
server: {
host: "0.0.0.0",
port: 5173,
proxy: {
"/api": {
target: proxyTarget,
changeOrigin: true,
},
},
},
optimizeDeps: {
include: ["diff"],
},
build: {
outDir: path.resolve(__dirname, "dist"),
emptyOutDir: true,
},
};
});