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.

33 lines
860 B
Plaintext

import { fileURLToPath, URL } from 'node:url'
import type { UserConfig, ConfigEnv } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
// https://vitejs.dev/config/
export default ({ command, mode }: ConfigEnv) => {
const root = process.cwd()
const env = loadEnv(mode, root)
const isBuild = command === 'build' // 可以根据开发 / 生产环境做区分
const proxyConfig = {
target: env.VITE_GLOB_APP_URL,
changeOrigin: true,
rewrite: (path: string) => path.replace(/^\/api/, '')
}
return {
plugins: [vue(), vueJsx()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
proxy: {
'/api': proxyConfig
},
open: true,
port: 16384
}
}
}