41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import { defineConfig, loadEnv } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), '');
|
|
const backendTarget = env.ADM_DEV_BACKEND ?? 'http://127.0.0.1:8085';
|
|
|
|
const basePath = env.VITE_BASE_PATH?.trim() || '/';
|
|
|
|
return {
|
|
base: basePath.endsWith('/') ? basePath : `${basePath}/`,
|
|
plugins: [react()],
|
|
server: {
|
|
host: true,
|
|
port: 5174,
|
|
strictPort: true,
|
|
allowedHosts: ['gadm.tkmind.cn', 'localhost', '127.0.0.1'],
|
|
proxy: {
|
|
'/api': backendTarget,
|
|
'/auth': backendTarget,
|
|
'/admin-api': backendTarget,
|
|
},
|
|
},
|
|
preview: {
|
|
host: '127.0.0.1',
|
|
port: 5174,
|
|
strictPort: true,
|
|
allowedHosts: ['gadm.tkmind.cn', 'localhost', '127.0.0.1'],
|
|
proxy: {
|
|
'/api': backendTarget,
|
|
'/auth': backendTarget,
|
|
'/admin-api': backendTarget,
|
|
},
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
emptyOutDir: true,
|
|
},
|
|
};
|
|
});
|