vite.config.ts 2.0 KB

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