vite.config.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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.lexiaoya.cn/'
  14. // const proxyUrl = 'https://test.lexiaoya.cn/'
  15. const proxyUrl = 'https://test.lexiaoya.cn/'
  16. // const proxyUrl = 'http://47.98.131.38:8989/'
  17. // const proxyUrl = 'http://192.168.3.20:8989/' // 邹旋
  18. // const proxyUrl = 'http://192.168.3.143:8989/' // 尚科
  19. // const proxyUrl = 'http://192.168.3.26:8989/' // 刘俊驰
  20. export default defineConfig({
  21. base: './',
  22. plugins: [
  23. vue(),
  24. vueJsx(),
  25. legacy({
  26. targets: ['> 0.25%, not dead'],
  27. ignoreBrowserslistConfig: true
  28. })
  29. // styleImport({
  30. // libs: [
  31. // {
  32. // libraryName: 'vant',
  33. // esModule: true,
  34. // resolveStyle: name => `../../vant/es/${name}/style`
  35. // }
  36. // ]
  37. // })
  38. ],
  39. resolve: {
  40. alias: {
  41. '@': resolve('./src'),
  42. '@common': resolve('./src/common'),
  43. '@components': resolve('./src/components'),
  44. '@store': resolve('./src/store'),
  45. '@views': resolve('./src/views')
  46. }
  47. },
  48. server: {
  49. host: '0.0.0.0',
  50. port: 1000,
  51. strictPort: true,
  52. cors: true,
  53. proxy: {
  54. '/api-oauth': {
  55. target: proxyUrl,
  56. changeOrigin: true
  57. },
  58. '/api-school': {
  59. target: proxyUrl,
  60. changeOrigin: true
  61. },
  62. '/api-teacher': {
  63. target: proxyUrl,
  64. changeOrigin: true
  65. },
  66. '/api-student': {
  67. target: proxyUrl,
  68. changeOrigin: true
  69. },
  70. '/api-backend': {
  71. target: proxyUrl,
  72. changeOrigin: true
  73. }
  74. }
  75. },
  76. build: {
  77. rollupOptions: {
  78. input: {
  79. index: resolve('index.html'),
  80. teacher: resolve('teacher.html'),
  81. school: resolve('school.html')
  82. }
  83. }
  84. // target: 'es2015',
  85. // cssTarget: 'chrome80',
  86. // reportCompressedSize: false,
  87. // chunkSizeWarningLimit: 500,
  88. }
  89. })