You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
  1. import { defineConfig, loadEnv } from 'vite'
  2. import react from '@vitejs/plugin-react'
  3. import { viteMockServe } from 'vite-plugin-mock'
  4. //import { TanStackRouterVite } from '@tanstack/router-vite-plugin'
  5. // https://vitejs.dev/config/
  6. export default defineConfig(({ mode }) => {
  7. // 根据当前工作目录中的 `mode` 加载 .env 文件
  8. // 设置第三个参数为 '' 来加载所有环境变量,而不管是否有 `VITE_` 前缀。
  9. const env = loadEnv(mode, process.cwd(), '')
  10. return {
  11. //定义别名的路径
  12. resolve: {
  13. alias: {
  14. '@': '/src',
  15. },
  16. },
  17. server: {
  18. proxy: {
  19. '/api': {
  20. target: env.API_URL,
  21. changeOrigin: true,
  22. rewrite: (path) => path
  23. }
  24. }
  25. },
  26. plugins: [
  27. react(),
  28. viteMockServe({
  29. // 是否启用 mock 功能(默认值:process.env.NODE_ENV !== 'production')
  30. enable: false,
  31. // mock 文件的根路径,默认值:'mocks'
  32. mockPath: 'mock',
  33. logger: true,
  34. }),
  35. //TanStackRouterVite(),
  36. ],
  37. }
  38. })