vite.config.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 = 'http://47.98.131.38:8989/'
  16. // const proxyUrl = 'http://192.168.3.20:8989/' // 邹旋
  17. // const proxyUrl = 'http://192.168.3.143:8989/' // 尚科
  18. // const proxyUrl = 'http://192.168.3.26:8989/' / 刘俊驰
  19. export default defineConfig({
  20. base: './',
  21. plugins: [
  22. vue(),
  23. vueJsx(),
  24. legacy({
  25. targets: ['> 0.25%, not dead'],
  26. ignoreBrowserslistConfig: true
  27. })
  28. // styleImport({
  29. // libs: [
  30. // {
  31. // libraryName: 'vant',
  32. // esModule: true,
  33. // resolveStyle: name => `../../vant/es/${name}/style`
  34. // }
  35. // ]
  36. // })
  37. ],
  38. resolve: {
  39. alias: {
  40. '@': resolve('./src'),
  41. '@common': resolve('./src/common'),
  42. '@components': resolve('./src/components'),
  43. '@store': resolve('./src/store'),
  44. '@views': resolve('./src/views')
  45. }
  46. },
  47. server: {
  48. host: '0.0.0.0',
  49. port: 1000,
  50. strictPort: true,
  51. cors: true,
  52. // https: 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. })