vite.config.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { fileURLToPath, URL } from 'node:url'
  2. import { defineConfig } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import AutoImport from 'unplugin-auto-import/vite'
  5. import Components from 'unplugin-vue-components/vite'
  6. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  7. // https://vitejs.dev/config/
  8. export default defineConfig({
  9. server: {
  10. cors: true,
  11. proxy: {
  12. // 代理所有 /api 的请求,该求情将被代理到 target 中
  13. '/api': {
  14. // 代理请求之后的请求地址(你的真实接口地址)
  15. target: 'https://cimweb.zjw.sh.cegn.cn:2007/data-business-prod/',
  16. //target: 'http://localhost:9250/',
  17. secure: false,
  18. ws: true,
  19. // 跨域
  20. changeOrigin: true,
  21. rewrite: (path) => path.replace(/^\/api/, ''),
  22. },
  23. '/addressapi': {
  24. // 代理请求之后的请求地址(你的真实接口地址)
  25. target: 'https://cimweb.zjw.sh.cegn.cn:2008/',
  26. //target: 'http://localhost:9250/',
  27. secure: false,
  28. ws: true,
  29. // 跨域
  30. changeOrigin: true,
  31. rewrite: (path) => path.replace(/^\/addressapi/, ''),
  32. },
  33. '/netapi': {
  34. // 代理请求之后的请求地址(你的真实接口地址)
  35. target: 'http://172.16.8.44:9250/low-altitude/',
  36. //target: 'http://localhost:9250/',
  37. secure: false,
  38. ws: true,
  39. // 跨域
  40. changeOrigin: true,
  41. rewrite: (path) => path.replace(/^\/netapi/, ''),
  42. },
  43. '/zwapi': {
  44. // 代理请求之后的请求地址(你的真实接口地址)
  45. target: 'http://10.90.9.143:9252/',
  46. //target: 'http://localhost:9250/',
  47. secure: false,
  48. ws: true,
  49. // 跨域
  50. changeOrigin: true,
  51. rewrite: (path) => path.replace(/^\/zwapi/, ''),
  52. },
  53. },
  54. },
  55. plugins: [
  56. vue(),
  57. AutoImport({
  58. resolvers: [ElementPlusResolver()],
  59. }),
  60. Components({
  61. resolvers: [ElementPlusResolver()],
  62. }),
  63. ],
  64. build: {
  65. outDir: 'low_altitude_interface',
  66. },
  67. resolve: {
  68. alias: {
  69. '@': fileURLToPath(new URL('./src', import.meta.url)),
  70. },
  71. },
  72. esbuild: {
  73. drop: ['console'],
  74. },
  75. css: {
  76. preprocessorOptions: {
  77. scss: {
  78. api: 'modern-compiler', // or 'modern'
  79. },
  80. },
  81. },
  82. base: '/low_altitude_interface/',
  83. })