vite.config.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. '/video': {
  48. // target: 'https://wuye.djchina.com/',
  49. target: 'http://172.18.0.76:9009/',
  50. changeOrigin: true,
  51. ws: true,
  52. rewrite: (path) => path.replace(/^\/video/, '/video')
  53. },
  54. }
  55. }
  56. }
  57. } else {
  58. return {
  59. // build配置
  60. ...config
  61. }
  62. }
  63. }