vite.config.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. }
  65. },
  66. build: {
  67. rollupOptions: {
  68. input: {
  69. index: path.resolve(__dirname, 'index.html'),
  70. about: path.resolve(__dirname, 'teacher.html')
  71. }
  72. }
  73. }
  74. });