vite.config.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import {fileURLToPath, URL} from 'node:url'
  2. import {defineConfig} from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import vueJsx from '@vitejs/plugin-vue-jsx'
  5. import vueDevTools from 'vite-plugin-vue-devtools'
  6. import svgicon from 'vite-plugin-svgicon'
  7. import * as path from 'path'
  8. // https://vite.dev/config/
  9. export default defineConfig({
  10. define: {
  11. 'process.env': {
  12. 'BASE_API': '/base_api'
  13. },
  14. },
  15. // 配置前端服务地址和端口
  16. server: {
  17. host: '0.0.0.0',
  18. port: 80,
  19. // 设置反向代理,跨域
  20. proxy: {
  21. '/dify_api': {
  22. target: 'http://10.8.11.96/v1',
  23. changeOrigin: true,
  24. rewrite: path => path.replace(/^\/dify_api/, '')
  25. },
  26. '/yuyan_api': {
  27. // 后台地址
  28. target: 'http://10.8.4.126:3386',
  29. changeOrigin: true,
  30. rewrite: path => path.replace(/^\/yuyan_api/, '')
  31. },
  32. '/zhxx_api': {
  33. // 后台地址
  34. target: 'http://10.8.4.135:8085/tba-zhxx/',
  35. changeOrigin: true,
  36. rewrite: path => path.replace(/^\/zhxx_api/, '')
  37. },
  38. '/gx_api': {
  39. // 共享平台
  40. target: 'http://10.8.4.136:8881/api/',
  41. changeOrigin: true,
  42. rewrite: path => path.replace(/^\/gx_api/, '')
  43. },
  44. '/szybh_api': {
  45. // 共享平台
  46. target: 'http://10.8.4.135:8083/',
  47. changeOrigin: true,
  48. rewrite: path => path.replace(/^\/szybh_api/, '')
  49. },
  50. '/nmc_api': {
  51. // 共享平台
  52. target: 'http://www.nmc.cn/',
  53. changeOrigin: true,
  54. rewrite: path => path.replace(/^\/nmc_api/, '')
  55. },
  56. '/video_api': {
  57. // 地听视频
  58. target: 'http://10.8.4.147:8090/',
  59. changeOrigin: true,
  60. rewrite: path => path.replace(/^\/video_api/, '')
  61. },
  62. '/videourl_api': {
  63. // 地听视频
  64. target: 'http://10.8.4.147:8800/',
  65. changeOrigin: true,
  66. rewrite: path => path.replace(/^\/videourl_api/, '')
  67. },
  68. '/tsq_api': {
  69. // 南水太师桥
  70. target: 'http://10.8.251.166:8001/',
  71. changeOrigin: true,
  72. rewrite: path => path.replace(/^\/tsq_api/, '')
  73. },
  74. }
  75. },
  76. plugins: [
  77. vue(),
  78. vueJsx(),
  79. vueDevTools(),
  80. svgicon({
  81. include: ['**/assets/svg/*.svg'],
  82. svgFilePath: path.join(__dirname, 'src/assets/svg'),
  83. }),
  84. ],
  85. resolve: {
  86. alias: {
  87. '@': fileURLToPath(new URL('./src', import.meta.url))
  88. }
  89. },
  90. css: {
  91. preprocessorOptions: {
  92. scss: {
  93. api: "modern-compiler", // or 'modern'
  94. // 自动导入定制化样式文件进行样式覆盖
  95. // additionalData: `
  96. // @use "@/assets/styles/element/index.scss";
  97. // `,
  98. }
  99. }
  100. },
  101. })