40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { fileURLToPath, URL } from 'node:url'
|
||
|
||
import Uni from '@uni-helper/plugin-uni'
|
||
import Components from '@uni-helper/vite-plugin-uni-components'
|
||
import { WotResolver } from '@uni-helper/vite-plugin-uni-components/resolvers'
|
||
import { defineConfig } from 'vite'
|
||
|
||
export default defineConfig({
|
||
resolve: {
|
||
alias: {
|
||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||
},
|
||
},
|
||
plugins: [
|
||
Components({
|
||
dts: true,
|
||
resolvers: [WotResolver()],
|
||
}),
|
||
// https://uni-helper.js.org/plugin-uni
|
||
Uni(),
|
||
],
|
||
server: {
|
||
proxy: {
|
||
// H5 联调:/api → 本地 GoFrame 服务
|
||
'/api': {
|
||
target: 'http://127.0.0.1:8000',
|
||
changeOrigin: true,
|
||
rewrite: path => path.replace(/^\/api/, ''),
|
||
},
|
||
// 服务封面 / MD 内图片 / 头像等静态资源(后端库内只存相对路径,H5 端经 BASE_URL=/api 拼不出 /static,
|
||
// 故单独代理静态目录到同一服务;小程序端用后端下发的绝对 cover_url,不走这里)
|
||
'/static': {
|
||
target: 'http://127.0.0.1:8000',
|
||
changeOrigin: true,
|
||
},
|
||
},
|
||
},
|
||
|
||
})
|