37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { defineConfig, loadEnv } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import path from 'node:path'
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), '')
|
|
const proxyTarget = String(env.VITE_DEV_PROXY_TARGET || 'http://127.0.0.1:80').trim()
|
|
const proxyToCoreDirectly = /(^|:)81(\/|$)/.test(proxyTarget)
|
|
|
|
return {
|
|
base: '/jy-salon-front/',
|
|
plugins: [vue()],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src')
|
|
}
|
|
},
|
|
server: {
|
|
port: 3001,
|
|
host: '0.0.0.0',
|
|
proxy: {
|
|
'/admin/api': {
|
|
target: proxyTarget,
|
|
changeOrigin: true,
|
|
rewrite: targetPath => proxyToCoreDirectly ? targetPath.replace(/^\/admin\/api/, '/admin') : targetPath
|
|
},
|
|
'/api': {
|
|
target: proxyTarget,
|
|
changeOrigin: true,
|
|
rewrite: targetPath => proxyToCoreDirectly ? targetPath.replace(/^\/api/, '') : targetPath
|
|
}
|
|
},
|
|
allowedHosts: true
|
|
}
|
|
}
|
|
})
|