vite.config.ts 2.5 KB

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