Files
CRM_Montzar/apps/web/vite.config.ts
T

53 lines
1.7 KiB
TypeScript
Raw Normal View History

import { defineConfig, loadEnv } from 'vite';
import tailwindcss from '@tailwindcss/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(),
tailwindcss(),
{
name: 'survive-windows-watcher',
configureServer(server) {
// On Windows, fs.watch throws EBUSY when a file is locked (brand SVGs,
// antivirus). An unhandled watcher "error" kills Vite and the page
// stays white because nothing is left to serve a refresh.
server.watcher.on('error', (err: NodeJS.ErrnoException) => {
console.error(
`[vite] watcher ${err?.code || 'error'} ignored: ${err?.message || err}`,
);
});
},
},
],
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://'),
},
},
},
};
});