initial commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
||||
|
||||
// 注意:页面跑在 5173,one-api 在 127.0.0.1:3100(SSH 隧道)—— 两者跨源。
|
||||
// 必须靠这个 proxy 把 /v1 转过去,让页面请求**同源相对路径**,否则带
|
||||
// Authorization 头会触发 OPTIONS 预检,one-api 未必放行。
|
||||
// Phase 2 改为 /Api/aiChat 后,这里只需再加一条同源转发。
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
vue(),
|
||||
Components({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
dts: false, // 不生成 components.d.ts,项目里 EP 组件都是显式 import 的
|
||||
}),
|
||||
],
|
||||
// 必须与 tsconfig.json 的 paths 保持一致,否则 @/ 开头的 import
|
||||
// 能过类型检查但在 dev/build 时解析失败。
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 5173,
|
||||
proxy: {
|
||||
'/v1': {
|
||||
target: 'http://127.0.0.1:3100',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user