52 lines
1.9 KiB
TypeScript
52 lines
1.9 KiB
TypeScript
import {defineConfig} from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import {resolve} from "path";
|
|
import {AppConfig} from './config'
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig(({mode}) => {
|
|
let configs = AppConfig['default'];
|
|
if(AppConfig[mode]){
|
|
configs = {...configs,...AppConfig[mode]}
|
|
}
|
|
return {
|
|
plugins: [react()],
|
|
base: mode == 'for-wm' ? './' : '/',
|
|
define: {
|
|
AppConfig: JSON.stringify({
|
|
SITE_URL: process.env.APP_SITE_URL || null,
|
|
API_PREFIX: process.env.APP_API_PREFIX || '/api',
|
|
FIY_WIRE_GATEWAY: process.env.FIY_WIRE_GATEWAY || 'https://gateway.flywire.com/v1/transfers',
|
|
SSO_AUTH_URL: process.env.SSO_AUTH_URL || 'https://portal.chuhai.edu.hk',
|
|
SSO_AUTH_CLIENT_KEY: process.env.AUTH_CLIENT_KEY || 'payment',
|
|
AUTH_TOKEN_KEY: process.env.AUTH_TOKEN_KEY || 'payment-auth-token',
|
|
...configs
|
|
}),
|
|
buildVersion: JSON.stringify((new Date()).toLocaleString()),
|
|
AppMode: JSON.stringify(mode)
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': resolve(__dirname, './src')
|
|
}
|
|
},
|
|
server: {
|
|
port:10086,
|
|
proxy: {
|
|
'/api': {
|
|
target: 'https://test-payment-be.hkchc.team', //
|
|
// target: 'http://127.0.0.1:50000', //
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/api/, '/api/')
|
|
},
|
|
'/staff-api': {
|
|
target: 'https://test-api.hkchc.team', //
|
|
// target: 'http://127.0.0.1:50000', //
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/staff-api/, '/api/')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|