2026-09-07 11:49:54 +03:30
|
|
|
import { defineConfig, loadEnv } from 'vite';
|
2026-11-03 16:51:51 +03:30
|
|
|
import tailwindcss from '@tailwindcss/vite';
|
2026-08-29 21:06:30 +03:30
|
|
|
import vue from '@vitejs/plugin-vue';
|
|
|
|
|
import { fileURLToPath, URL } from 'node:url';
|
|
|
|
|
|
2026-09-07 11:49:54 +03:30
|
|
|
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 {
|
2026-11-25 16:53:04 +03:30
|
|
|
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}`,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
2026-09-07 11:49:54 +03:30
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
|
|
|
'@mento/shared': fileURLToPath(new URL('../../packages/shared/src/index.ts', import.meta.url)),
|
2026-08-29 21:06:30 +03:30
|
|
|
},
|
|
|
|
|
},
|
2026-09-07 11:49:54 +03:30
|
|
|
server: {
|
|
|
|
|
host: '127.0.0.1',
|
|
|
|
|
port: 5173,
|
|
|
|
|
proxy: {
|
|
|
|
|
'/api': {
|
|
|
|
|
target: apiTarget,
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
secure: apiTarget.startsWith('https://'),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
2026-08-29 21:06:30 +03:30
|
|
|
});
|