You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.8 KiB
JavaScript
42 lines
1.8 KiB
JavaScript
import { defineConfig, loadEnv } from "vite";
|
|
import react from "@vitejs/plugin-react";
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
import path from "path";
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), "");
|
|
const efficiencyV2Target = env.VITE_EFFICIENCY_V2_PROXY_TARGET ||
|
|
env.VITE_EFFICIENCY_V2_URL ||
|
|
"https://pltu_dt.digitaltwin.my.id";
|
|
return {
|
|
plugins: [react(), tailwindcss()],
|
|
resolve: {
|
|
alias: [
|
|
// More specific aliases must come before the generic "@" alias
|
|
{ find: "@/components", replacement: path.resolve(__dirname, "./src/shared/components") },
|
|
{ find: "@/lib/api-url", replacement: path.resolve(__dirname, "./src/shared/api-url") },
|
|
{ find: "@/lib/fetcher", replacement: path.resolve(__dirname, "./src/shared/fetcher") },
|
|
{ find: "@/lib/APIs/types", replacement: path.resolve(__dirname, "./src/shared/types") },
|
|
{ find: "sweetalert2", replacement: path.resolve(__dirname, "./src/shared/shims/sweetalert2.ts") },
|
|
{ find: "@", replacement: path.resolve(__dirname, "./src") },
|
|
],
|
|
},
|
|
server: {
|
|
port: 3002,
|
|
host: true,
|
|
allowedHosts: ["v2.digitaltwin.my.id"],
|
|
proxy: {
|
|
"/api-proxy": {
|
|
target: "http://192.168.1.82:8000",
|
|
changeOrigin: true,
|
|
rewrite: (p) => p.replace(/^\/api-proxy/, ""),
|
|
},
|
|
"/efficiency-v2-api": {
|
|
target: efficiencyV2Target,
|
|
changeOrigin: true,
|
|
rewrite: (p) => p.replace(/^\/efficiency-v2-api/, ""),
|
|
},
|
|
},
|
|
},
|
|
};
|
|
});
|