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.

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