vite.config.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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://mstutest.dayaedu.com/';
  14. const proxyUrl = 'https://dev.colexiu.com/'
  15. export default defineConfig({
  16. base: './',
  17. plugins: [
  18. vue(),
  19. vueJsx(),
  20. legacy({
  21. targets: ['> 0.25%, not dead'],
  22. ignoreBrowserslistConfig: true
  23. }),
  24. styleImport({
  25. libs: [
  26. {
  27. libraryName: 'vant',
  28. esModule: true,
  29. resolveStyle: name => `vant/es/${name}/style`
  30. }
  31. ]
  32. })
  33. ],
  34. resolve: {
  35. alias: {
  36. '@': resolve('./src'),
  37. '@common': resolve('./src/common'),
  38. '@components': resolve('./src/components'),
  39. '@business-components': resolve('./src/business-components'),
  40. '@store': resolve('./src/store'),
  41. '@views': resolve('./src/views')
  42. }
  43. },
  44. server: {
  45. host: '0.0.0.0',
  46. port: 5000,
  47. strictPort: true,
  48. proxy: {
  49. '/api-auth': {
  50. target: proxyUrl,
  51. changeOrigin: true
  52. },
  53. '/api-student': {
  54. target: proxyUrl,
  55. changeOrigin: true
  56. },
  57. '/api-teacher': {
  58. target: proxyUrl,
  59. changeOrigin: true
  60. },
  61. '/api-web': {
  62. target: proxyUrl,
  63. changeOrigin: true
  64. },
  65. '/api-cms': {
  66. target: proxyUrl,
  67. changeOrigin: true
  68. },
  69. '/music': {
  70. target: proxyUrl,
  71. changeOrigin: true
  72. },
  73. '/api-mall-portal': {
  74. target: proxyUrl,
  75. changeOrigin: true
  76. }
  77. }
  78. },
  79. build: {
  80. rollupOptions: {
  81. input: {
  82. index: resolve('index.html'),
  83. teacher: resolve('teacher.html')
  84. }
  85. }
  86. }
  87. })