vite.config.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import path from 'path';
  2. import commonjs from 'vite-plugin-commonjs'
  3. import { defineConfig } from 'vite'
  4. import uni from '@dcloudio/vite-plugin-uni'
  5. import { defaultURL } from './src/config/httpConfig';
  6. export default defineConfig({
  7. plugins: [
  8. uni(),
  9. commonjs(),
  10. ],
  11. css: {
  12. preprocessorOptions: {
  13. scss: {
  14. api: 'modern-compiler' // 使用新的现代编译器API,避免旧版JS API弃用警告
  15. }
  16. }
  17. },
  18. resolve: {
  19. alias: {
  20. '@vue/shared': '@vue/shared/dist/shared.esm-bundler.js',
  21. '@': 'src',
  22. 'jweixin-module': path.resolve(__dirname, 'src/js_sdk/jweixin-module/index.js')
  23. }
  24. },
  25. optimizeDeps: {
  26. entries: [
  27. 'src/main.js',
  28. 'src/App.vue',
  29. 'src/pages/**/*.vue'
  30. ],
  31. include: [
  32. 'tim-wx-sdk',
  33. 'tim-js-sdk',
  34. 'trtc-js-sdk',
  35. 'cos-wx-sdk-v5',
  36. 'jweixin-module'
  37. ]
  38. },
  39. build: {
  40. chunkSizeWarningLimit: 1000,
  41. rollupOptions: {
  42. output: {
  43. manualChunks(id) {
  44. if (!id.includes('node_modules')) return;
  45. if (/[\\/]node_modules[\\/](tim-|trtc-|cos-|webrtc-adapter)/.test(id)) {
  46. return 'vendor-tencent';
  47. }
  48. if (/[\\/]node_modules[\\/](@vant|weui-miniprogram|vant-aliapp)/.test(id)) {
  49. return 'vendor-ui';
  50. }
  51. if (/[\\/]node_modules[\\/](@dcloudio|vue|vuex|vue-router)/.test(id)) {
  52. return 'vendor-core';
  53. }
  54. }
  55. }
  56. }
  57. },
  58. server: {
  59. host: '0.0.0.0',
  60. warmup: {
  61. clientFiles: [
  62. 'src/main.js',
  63. 'src/App.vue',
  64. 'src/**/*.vue'
  65. ]
  66. },
  67. allowedHosts: [
  68. 'frp.12123wzcx.com' // 允许所有 frp.12123wzcx.com 的子域名
  69. ],
  70. proxy: {
  71. '/bdhealth': {
  72. target: defaultURL,
  73. changeOrigin: true,
  74. rewrite: (path) => path.replace('/bdhealth', '/bdhealth')
  75. },
  76. '/openID': {
  77. target: defaultURL,
  78. changeOrigin: true,
  79. rewrite: (path) => path.replace('/openID', '/openID')
  80. },
  81. '/images': {
  82. target: defaultURL,
  83. changeOrigin: true,
  84. rewrite: (path) => path.replace('/images', '/images')
  85. },
  86. // '/MP_verify_mRdA5h8p5Phywrus.txt': {
  87. // target: 'http://localhost:81',
  88. // changeOrigin: true,
  89. // rewrite: (path) => path.replace('/MP_verify_mRdA5h8p5Phywrus.txt', '/MP_verify_mRdA5h8p5Phywrus.txt')
  90. // },
  91. '/ws/': {
  92. target: 'https://apis.map.qq.com',
  93. changeOrigin: true,
  94. rewrite: (path) => path.replace('/ws/', '/ws/')
  95. },
  96. '/EMRFile': {
  97. target: defaultURL,
  98. changeOrigin: true,
  99. },
  100. '/fileUp/': {
  101. target: 'https://np.h03.p0551.com',
  102. changeOrigin: true,
  103. rewrite: (path) => path.replace('/fileUp/', '')
  104. },
  105. '/pingd': {
  106. target: 'https://pingtas.qq.com',
  107. changeOrigin: true,
  108. },
  109. '/patientapp/images': {
  110. target: defaultURL,
  111. changeOrigin: true,
  112. rewrite: (path) => path.replace('/patientapp/images', '/images')
  113. },
  114. '/uploadFile': {
  115. target: defaultURL,
  116. changeOrigin: true,
  117. rewrite: (path) => path.replace('/uploadFile', '/uploadFile')
  118. },
  119. }
  120. },
  121. })