add:新增接口代理

This commit was merged in pull request #7.
This commit is contained in:
zlong committed 2024-12-03 15:33:37 +08:00
1 parent 23cc6b6d35
commit f1eec0ac6d
9 files changed
+306 -4

No files matched your search

+12 -2
View File
@@ -8,13 +8,14 @@ import postcssPresetEnv from 'postcss-preset-env'
import tailwindcss from 'tailwindcss'
import nested from 'tailwindcss/nesting'
import AutoImport from 'unplugin-auto-import/vite'
import { defineConfig } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import tailwindcssConfig from './tailwind.config' // 注意匹配实际文件
// 注意匹配实际文件
// https://vitejs.dev/config/
export default async () => {
export default async ({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return defineConfig({
css: {
postcss: {
@@ -30,6 +31,15 @@ export default async () => {
],
},
},
server: {
proxy: {
'/api': {
target: env.VITE_PROXY_ENDPOINT,
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, ''),
},
},
},
plugins: [
// https://github.com/uni-helper/vite-plugin-uni-manifest
UniHelperManifest(),