vite.config.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 = 'http://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. '@store': resolve('./src/store'),
  40. '@views': resolve('./src/views')
  41. }
  42. },
  43. server: {
  44. host: '0.0.0.0',
  45. port: 5000,
  46. strictPort: true,
  47. proxy: {
  48. '/api-auth': {
  49. target: proxyUrl,
  50. changeOrigin: true
  51. },
  52. '/api-student': {
  53. target: proxyUrl,
  54. changeOrigin: true
  55. },
  56. '/api-teacher': {
  57. target: proxyUrl,
  58. changeOrigin: true
  59. },
  60. '/api-web': {
  61. target: proxyUrl,
  62. changeOrigin: true
  63. },
  64. '/music': {
  65. target: proxyUrl,
  66. changeOrigin: true
  67. }
  68. }
  69. },
  70. build: {
  71. rollupOptions: {
  72. input: {
  73. index: resolve('index.html'),
  74. teacher: resolve('teacher.html')
  75. }
  76. }
  77. }
  78. })