vite.config.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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/sz/tba-gx/',
  30. changeOrigin: true,
  31. rewrite: path => path.replace(/^\/gx_api/, '')
  32. },
  33. '/gx_gj_api': {
  34. // 共享平台
  35. target: 'http://10.8.4.136:8881/api/sq_zh/',
  36. changeOrigin: true,
  37. rewrite: path => path.replace(/^\/gx_gj_api/, '')
  38. },
  39. '/nmc_api': {
  40. // 共享平台
  41. target: 'http://www.nmc.cn/',
  42. changeOrigin: true,
  43. rewrite: path => path.replace(/^\/nmc_api/, '')
  44. },
  45. '/video_api': {
  46. // 地听视频
  47. target: 'http://10.8.48.234:8081/',
  48. changeOrigin: true,
  49. rewrite: path => path.replace(/^\/video_api/, '')
  50. },
  51. }
  52. },
  53. plugins: [
  54. vue(),
  55. vueJsx(),
  56. vueDevTools(),
  57. svgicon({
  58. include: ['**/assets/svg/*.svg'],
  59. svgFilePath: path.join(__dirname, 'src/assets/svg'),
  60. }),
  61. ],
  62. resolve: {
  63. alias: {
  64. '@': fileURLToPath(new URL('./src', import.meta.url))
  65. }
  66. },
  67. css: {
  68. preprocessorOptions: {
  69. scss: {
  70. api: "modern-compiler", // or 'modern'
  71. // 自动导入定制化样式文件进行样式覆盖
  72. // additionalData: `
  73. // @use "@/assets/styles/element/index.scss";
  74. // `,
  75. }
  76. }
  77. },
  78. })