vite.config.ts 631 B

123456789101112131415161718192021222324
  1. import { defineConfig } from "vite";
  2. import uni from "@dcloudio/vite-plugin-uni";
  3. import { resolve } from "path";
  4. // https://vitejs.dev/config/
  5. export default defineConfig({
  6. plugins: [uni()],
  7. resolve: {
  8. // 配置别名
  9. alias: {
  10. "@": resolve(__dirname, "src"),
  11. },
  12. },
  13. server: {
  14. proxy: {
  15. [process.env.VUE_APP_BASE_API as string]: {
  16. target: process.env.VUE_APP_API_URL, // 后端API服务器的地址
  17. changeOrigin: true, // 是否改变源地址
  18. rewrite: (path) =>
  19. path.replace(`/^\/${process.env.VUE_APP_BASE_API}/`, ""), // 重写路径
  20. },
  21. },
  22. },
  23. });