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.

63 lines
1.6 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 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. cors: {
  22. origin: '*'
  23. },
  24. proxy: {
  25. '/api/v1/movie': {
  26. target: 'http://47.113.117.106:10000',
  27. changeOrigin: true,
  28. rewrite: (path) => {
  29. return path
  30. }
  31. },
  32. '/api': {
  33. target: env.API_URL,
  34. changeOrigin: true,
  35. rewrite: (path) => {
  36. return path
  37. }
  38. }
  39. },
  40. },
  41. plugins: [
  42. react({
  43. babel: {
  44. presets: [ 'jotai/babel/preset' ],
  45. plugins: [ jotaiDebugLabel, jotaiReactRefresh ]
  46. },
  47. }),
  48. viteMockServe({
  49. // 是否启用 mock 功能(默认值:process.env.NODE_ENV !== 'production')
  50. enable: false,
  51. // mock 文件的根路径,默认值:'mocks'
  52. mockPath: 'mock',
  53. logger: true,
  54. }),
  55. //TanStackRouterVite(),
  56. ],
  57. }
  58. })