You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1021 B
32 lines
1021 B
/// <reference types="vitest/config" />
|
|
import path from 'node:path'
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), '')
|
|
/* مقصد بکاند برای پراکسیِ dev — همهٔ '/api/*' بدون CORS به اینجا میرود. */
|
|
const apiTarget = env.VITE_API_TARGET ?? 'http://localhost:8000'
|
|
|
|
return {
|
|
plugins: [react(), tailwindcss()],
|
|
resolve: {
|
|
alias: { '@': path.resolve(__dirname, './src') },
|
|
},
|
|
server: {
|
|
proxy: {
|
|
'/api': {
|
|
target: apiTarget,
|
|
changeOrigin: true,
|
|
/* بکاند پیشوند '/api' ندارد؛ آن را حذف میکنیم تا به ریشه برسد. */
|
|
rewrite: (p) => p.replace(/^\/api/, ''),
|
|
},
|
|
},
|
|
},
|
|
test: {
|
|
environment: 'node',
|
|
include: ['src/**/*.test.{ts,tsx}'],
|
|
},
|
|
}
|
|
})
|