import { defineConfig, loadEnv } from 'vite'; import vue from '@vitejs/plugin-vue'; import { fileURLToPath, URL } from 'node:url'; const PROD_API = 'https://crm.montzar.ir'; export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), ''); const apiTarget = env.MENTO_DEV_API || process.env.MENTO_DEV_API || PROD_API; const usingLocalApi = apiTarget.includes('127.0.0.1') || apiTarget.includes('localhost'); // eslint-disable-next-line no-console console.log(`[montact] UI → ${apiTarget}${usingLocalApi ? ' (API لوکال)' : ' (سرور اصلی)'}`); return { plugins: [vue()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), '@mento/shared': fileURLToPath(new URL('../../packages/shared/src/index.ts', import.meta.url)), }, }, server: { host: '127.0.0.1', port: 5173, proxy: { '/api': { target: apiTarget, changeOrigin: true, secure: apiTarget.startsWith('https://'), }, }, }, }; });