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.

47 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. babel: {
  29. presets: ['jotai/babel/preset'],
  30. },
  31. }),
  32. viteMockServe({
  33. // 是否启用 mock 功能(默认值:process.env.NODE_ENV !== 'production')
  34. enable: false,
  35. // mock 文件的根路径,默认值:'mocks'
  36. mockPath: 'mock',
  37. logger: true,
  38. }),
  39. //TanStackRouterVite(),
  40. ],
  41. }
  42. })