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: [
  18. vue()
  19. ]
  20. }
  21. if (command === 'serve') {
  22. return {
  23. // serve配置
  24. ...config,
  25. server:{
  26. port: 3001,
  27. proxy:{
  28. '/landcrm': {
  29. target: 'http://172.18.0.23/',
  30. // target: 'https://ebeitest.wuyeface.com:1188/',
  31. // target: 'http://101.200.225.123/',
  32. changeOrigin: true,
  33. ws: true,
  34. rewrite: (path) => path.replace(/^\/landcrm/, '/landcrm')
  35. },
  36. '/device': {
  37. target: 'http://172.18.0.23/',
  38. // target: 'https://ebeitest.wuyeface.com:1188/',
  39. // target: 'http://101.200.225.123/',
  40. changeOrigin: true,
  41. ws: true,
  42. rewrite: (path) => path.replace(/^\/device/, '/device')
  43. },
  44. '/hospital': {
  45. // target: 'http://172.18.0.23/',
  46. // target: 'http://172.18.0.78:9090/',
  47. target: 'http://172.18.1.79:9091/',
  48. // target: 'https://ebeitests.wuyeface.com:1188/',
  49. // target: 'http://101.200.225.123/',
  50. changeOrigin: true,
  51. ws: true,
  52. rewrite: (path) => path.replace(/^\/hospital/, '/hospital')
  53. },
  54. }
  55. }
  56. }
  57. } else {
  58. return {
  59. // build配置
  60. ...config
  61. }
  62. }
  63. }