vite.config.ts 1.7 KB

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