vite.config.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. '/base_api': {
  22. target: 'http://localhost:18093',
  23. changeOrigin: true,
  24. rewrite: path => path.replace(/^\/base_api/, '')
  25. },
  26. '/dify_api': {
  27. target: 'http://10.8.11.96/v1',
  28. changeOrigin: true,
  29. rewrite: path => path.replace(/^\/dify_api/, '')
  30. },
  31. '/yuyan_api': {
  32. // 后台地址
  33. target: 'http://10.8.4.126:3386',
  34. changeOrigin: true,
  35. rewrite: path => path.replace(/^\/yuyan_api/, '')
  36. },
  37. '/zhxx_api': {
  38. // 后台地址
  39. target: 'http://10.8.4.135:8085/tba-zhxx',
  40. changeOrigin: true,
  41. rewrite: path => path.replace(/^\/zhxx_api/, '')
  42. },
  43. '/gx_api': {
  44. // 共享平台
  45. target: 'http://10.8.4.136:8881/api/',
  46. changeOrigin: true,
  47. rewrite: path => path.replace(/^\/gx_api/, '')
  48. },
  49. '/szybh_api': {
  50. // 共享平台
  51. target: 'http://10.8.4.135:8083/',
  52. changeOrigin: true,
  53. rewrite: path => path.replace(/^\/szybh_api/, '')
  54. },
  55. '/nmc_api': {
  56. // 共享平台
  57. target: 'http://www.nmc.cn/',
  58. changeOrigin: true,
  59. rewrite: path => path.replace(/^\/nmc_api/, '')
  60. },
  61. '/video_api': {
  62. // 地听视频
  63. target: 'http://10.8.4.147:8090/',
  64. changeOrigin: true,
  65. rewrite: path => path.replace(/^\/video_api/, '')
  66. },
  67. '/videourl_api': {
  68. // 地听视频
  69. target: 'http://10.8.4.147:8800/',
  70. changeOrigin: true,
  71. rewrite: path => path.replace(/^\/videourl_api/, '')
  72. },
  73. }
  74. },
  75. plugins: [
  76. vue(),
  77. vueJsx(),
  78. vueDevTools(),
  79. svgicon({
  80. include: ['**/assets/svg/*.svg'],
  81. svgFilePath: path.join(__dirname, 'src/assets/svg'),
  82. }),
  83. ],
  84. resolve: {
  85. alias: {
  86. '@': fileURLToPath(new URL('./src', import.meta.url))
  87. }
  88. },
  89. css: {
  90. preprocessorOptions: {
  91. scss: {
  92. api: "modern-compiler", // or 'modern'
  93. // 自动导入定制化样式文件进行样式覆盖
  94. // additionalData: `
  95. // @use "@/assets/styles/element/index.scss";
  96. // `,
  97. }
  98. }
  99. },
  100. })