vite.config.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. export default defineConfig({
  15. plugins: [
  16. vue(),
  17. vueJsx(),
  18. legacy({
  19. targets: ['> 0.25%, not dead'],
  20. ignoreBrowserslistConfig: true
  21. }),
  22. styleImport({
  23. libs: [
  24. {
  25. libraryName: 'vant',
  26. esModule: true,
  27. resolveStyle: name => `vant/es/${name}/style`
  28. }
  29. ]
  30. })
  31. ],
  32. resolve: {
  33. alias: {
  34. '@': resolve('./src'),
  35. '@common': resolve('./src/common'),
  36. '@components': resolve('./src/components'),
  37. '@store': resolve('./src/store'),
  38. '@views': resolve('./src/views')
  39. }
  40. },
  41. server: {
  42. host: '0.0.0.0',
  43. port: 5000,
  44. strictPort: true,
  45. proxy: {
  46. '/api-auth': {
  47. target: proxyUrl,
  48. changeOrigin: true
  49. },
  50. '/api-student': {
  51. target: proxyUrl,
  52. changeOrigin: true
  53. },
  54. '/api-teacher': {
  55. target: proxyUrl,
  56. changeOrigin: true
  57. }
  58. }
  59. },
  60. build: {
  61. rollupOptions: {
  62. input: {
  63. index: path.resolve(__dirname, 'index.html'),
  64. about: path.resolve(__dirname, 'teacher.html')
  65. }
  66. }
  67. }
  68. });