vite.config.ts 2.2 KB

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