vite.config.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import styleImport from 'vite-plugin-style-import'
  4. import vueJsx from '@vitejs/plugin-vue-jsx'
  5. import legacy from '@vitejs/plugin-legacy'
  6. // eslint-disable-next-line @typescript-eslint/no-var-requires
  7. const path = require('path')
  8. function resolve(dir: string) {
  9. return path.join(__dirname, dir)
  10. }
  11. // https://vitejs.dev/config/
  12. // https://github.com/vitejs/vite/issues/1930 .env
  13. // const proxyUrl = 'https://online.colexiu.com/'
  14. const proxyUrl = 'https://test.colexiu.com/'
  15. // const proxyUrl = 'http://192.168.3.14:8000/'
  16. export default defineConfig({
  17. base: './',
  18. plugins: [
  19. vue(),
  20. vueJsx(),
  21. legacy({
  22. targets: ['> 0.25%, not dead'],
  23. ignoreBrowserslistConfig: true
  24. // targets: ['chrome 52'],
  25. // additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
  26. // renderLegacyChunks: true,
  27. // polyfills: [
  28. // 'es.symbol',
  29. // 'es.array.filter',
  30. // 'es.promise',
  31. // 'es.promise.finally',
  32. // 'es/map',
  33. // 'es/set',
  34. // 'es.array.for-each',
  35. // 'es.object.define-properties',
  36. // 'es.object.define-property',
  37. // 'es.object.get-own-property-descriptor',
  38. // 'es.object.get-own-property-descriptors',
  39. // 'es.object.keys',
  40. // 'es.object.to-string',
  41. // 'web.dom-collections.for-each',
  42. // 'esnext.global-this',
  43. // 'esnext.string.match-all'
  44. // ]
  45. }),
  46. styleImport({
  47. libs: [
  48. {
  49. libraryName: 'vant',
  50. esModule: true,
  51. resolveStyle: name => `vant/es/${name}/style`
  52. }
  53. ]
  54. })
  55. ],
  56. resolve: {
  57. alias: {
  58. '@': resolve('./src'),
  59. '@common': resolve('./src/common'),
  60. '@components': resolve('./src/components'),
  61. '@business-components': resolve('./src/business-components'),
  62. '@store': resolve('./src/store'),
  63. '@views': resolve('./src/views')
  64. }
  65. },
  66. server: {
  67. host: '0.0.0.0',
  68. port: 5000,
  69. strictPort: true,
  70. cors: true,
  71. proxy: {
  72. '/api-auth': {
  73. target: proxyUrl,
  74. changeOrigin: true
  75. },
  76. '/api-student': {
  77. target: proxyUrl,
  78. changeOrigin: true
  79. },
  80. '/api-teacher': {
  81. target: proxyUrl,
  82. changeOrigin: true
  83. },
  84. '/api-web': {
  85. target: proxyUrl,
  86. changeOrigin: true
  87. },
  88. '/api-cms': {
  89. target: proxyUrl,
  90. changeOrigin: true
  91. },
  92. '/api-admin': {
  93. target: proxyUrl,
  94. changeOrigin: true
  95. },
  96. '/music': {
  97. target: proxyUrl,
  98. changeOrigin: true
  99. },
  100. '/api-mall-portal': {
  101. target: proxyUrl,
  102. changeOrigin: true
  103. },
  104. '/api-tenant': {
  105. target: proxyUrl,
  106. changeOrigin: true
  107. }
  108. }
  109. },
  110. build: {
  111. rollupOptions: {
  112. input: {
  113. index: resolve('index.html'),
  114. teacher: resolve('teacher.html'),
  115. tenant: resolve('tenant.html')
  116. }
  117. }
  118. }
  119. })