vite.config.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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://ebeitest.wuyeface.com:1188/',
  28. changeOrigin: true,
  29. ws: true,
  30. rewrite: (path) => path.replace(/^\/landcrm/, '/landcrm')
  31. },
  32. '/neikong': {
  33. target: 'https://wuye.djchina.com/',
  34. // target: 'http://172.18.1.40:8185/',
  35. changeOrigin: true,
  36. ws: true,
  37. rewrite: (path) => path.replace(/^\/neikong/, '/neikong')
  38. },
  39. '/datashow': {
  40. target: 'https://wuye.djchina.com/',
  41. // target: 'http://172.18.1.40:8185/',
  42. changeOrigin: true,
  43. ws: true,
  44. rewrite: (path) => path.replace(/^\/datashow/, '/datashow')
  45. },
  46. }
  47. }
  48. }
  49. } else {
  50. return {
  51. // build配置
  52. ...config
  53. }
  54. }
  55. }