vite.config.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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://test.dayaedu.com/'
  14. // const proxyUrl = 'https://dev.colexiu.com/'
  15. // const proxyUrl = 'http://192.168.3.26: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. }),
  25. styleImport({
  26. libs: [
  27. {
  28. libraryName: 'vant',
  29. esModule: true,
  30. resolveStyle: name => `vant/es/${name}/style`
  31. }
  32. ]
  33. })
  34. ],
  35. resolve: {
  36. alias: {
  37. '@': resolve('./src'),
  38. '@common': resolve('./src/common'),
  39. '@components': resolve('./src/components'),
  40. '@business-components': resolve('./src/business-components'),
  41. '@store': resolve('./src/store'),
  42. '@views': resolve('./src/views')
  43. }
  44. },
  45. server: {
  46. host: '0.0.0.0',
  47. port: 9002,
  48. strictPort: true,
  49. cors: true,
  50. proxy: {
  51. '/api-auth': {
  52. target: proxyUrl,
  53. changeOrigin: true
  54. },
  55. '/api-student': {
  56. target: proxyUrl,
  57. changeOrigin: true
  58. },
  59. '/api-teacher': {
  60. target: proxyUrl,
  61. changeOrigin: true
  62. },
  63. '/api-web': {
  64. target: proxyUrl,
  65. changeOrigin: true
  66. },
  67. '/api-cms': {
  68. target: proxyUrl,
  69. changeOrigin: true
  70. },
  71. '/api-admin': {
  72. target: proxyUrl,
  73. changeOrigin: true
  74. },
  75. '/music': {
  76. target: proxyUrl,
  77. changeOrigin: true
  78. },
  79. '/api-mall-portal': {
  80. target: proxyUrl,
  81. changeOrigin: true
  82. }
  83. }
  84. },
  85. build: {
  86. rollupOptions: {
  87. input: {
  88. index: resolve('index.html')
  89. }
  90. }
  91. }
  92. })