vite.config.js 1.5 KB

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