vite.config.js 3.2 KB

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