vite.config.ts 1.8 KB

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