vite.config.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import viteESLint from '@ehutch79/vite-eslint'
  4. import path from 'path'
  5. export default ({ command, mode }) => {
  6. let config = {
  7. alias:{
  8. '@': path.resolve(__dirname, 'src'),
  9. 'api': path.resolve(__dirname, 'src/api'),
  10. 'comps': path.resolve(__dirname, 'src/components'),
  11. 'css': path.resolve(__dirname, 'src/assets/css'),
  12. 'images': path.resolve(__dirname, 'src/assets/images'),
  13. 'router': path.resolve(__dirname, 'src/router'),
  14. 'utils': path.resolve(__dirname, 'src/utils'),
  15. },
  16. base: './',
  17. plugins: [vue(), viteESLint()]
  18. }
  19. if (command === 'serve') {
  20. return {
  21. // serve配置
  22. ...config,
  23. server:{
  24. port: 3001,
  25. proxy:{
  26. '/landcrm': {
  27. target: 'https://wuye.djchina.com/',
  28. // target: 'https://ebeitest.wuyeface.com:1188/',
  29. changeOrigin: true,
  30. ws: true,
  31. rewrite: (path) => path.replace(/^\/landcrm/, '/landcrm')
  32. },
  33. '/neikong': {
  34. target: 'https://wuye.djchina.com/',
  35. // target: 'https://ebeitest.wuyeface.com:1188/',
  36. changeOrigin: true,
  37. ws: true,
  38. rewrite: (path) => path.replace(/^\/neikong/, '/neikong')
  39. },
  40. '/datashow': {
  41. target: 'https://wuye.djchina.com/',
  42. // target: 'https://ebeitest.wuyeface.com:1188/',
  43. changeOrigin: true,
  44. ws: true,
  45. rewrite: (path) => path.replace(/^\/datashow/, '/datashow')
  46. },
  47. }
  48. }
  49. }
  50. } else {
  51. return {
  52. // build配置
  53. ...config
  54. }
  55. }
  56. }