42 lines
912 B
TypeScript
42 lines
912 B
TypeScript
import path from "node:path";
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
import react from "@vitejs/plugin-react";
|
|
import { defineConfig, loadEnv } from "vite";
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const isProduction = mode === "production";
|
|
const env = loadEnv(mode, process.cwd(), "");
|
|
|
|
const backendUrl =
|
|
env.VITE_PROXY_TARGET?.replace(/\/api\/?$/, "") ||
|
|
"http://localhost:3000";
|
|
|
|
return {
|
|
plugins: [react(), tailwindcss()],
|
|
|
|
resolve: {
|
|
alias: {
|
|
"@": path.resolve(__dirname, "./src"),
|
|
},
|
|
},
|
|
|
|
server: {
|
|
proxy: {
|
|
"/api": {
|
|
target: backendUrl,
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
|
|
build: {
|
|
target: "esnext",
|
|
minify: "esbuild",
|
|
sourcemap: !isProduction,
|
|
reportCompressedSize: false,
|
|
},
|
|
esbuild: {
|
|
drop: isProduction ? ["console", "debugger"] : [],
|
|
},
|
|
};
|
|
}); |