vite.config.ts 2.5 KB

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