vite.config.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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://www.gzjlzhwy.com:4433/',
  28. changeOrigin: true,
  29. ws: true,
  30. rewrite: (path) => path.replace(/^\/landcrm/, '/landcrm')
  31. },
  32. '/device': {
  33. target: 'https://www.gzjlzhwy.com:4433/',
  34. changeOrigin: true,
  35. ws: true,
  36. rewrite: (path) => path.replace(/^\/device/, '/device')
  37. },
  38. '/attendance': {
  39. target: 'https://www.gzjlzhwy.com:4433/',
  40. changeOrigin: true,
  41. ws: true,
  42. rewrite: (path) => path.replace(/^\/attendance/, '/attendance')
  43. },
  44. }
  45. }
  46. }
  47. } else {
  48. return {
  49. // build配置
  50. ...config
  51. }
  52. }
  53. }