You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
976 B
TypeScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import vue from '@vitejs/plugin-vue'
import { defineConfig, loadEnv } from 'electron-vite'
import { resolve } from 'path'
/**
* 开发时页面在 Vite如 localhost:5173若 axios 直连 localhost:8845 会触发浏览器 CORS。
* 将 /api 代理到真实后端,配合 service.ts 在 DEV 下使用同源路径 /api/queue/caller。
* 联调其它地址时在项目根 .env.development 设置VITE_DEV_PROXY_TARGET=http://host:8845
*/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const devProxyTarget = env.VITE_DEV_PROXY_TARGET || 'http://127.0.0.1:8845'
return {
main: {},
preload: {},
renderer: {
resolve: {
alias: {
'@renderer': resolve('src/renderer/src'),
},
},
plugins: [vue()],
server: {
proxy: {
'/api': {
target: devProxyTarget,
changeOrigin: true,
},
},
},
},
}
})