vite.config.js 1.5 KB

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