vite.config.ts 2.1 KB

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