vite.config.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { defineConfig } from 'vite';
  2. import vue from '@vitejs/plugin-vue';
  3. import vueJsx from '@vitejs/plugin-vue-jsx';
  4. import Components from 'unplugin-vue-components/vite';
  5. import { VantResolver } from 'unplugin-vue-components/resolvers';
  6. import viteESLint from 'vite-plugin-eslint';
  7. import legacy from '@vitejs/plugin-legacy'
  8. // eslint-disable-next-line @typescript-eslint/no-var-requires
  9. const path = require('path');
  10. function resolve(dir: string) {
  11. return path.join(__dirname, dir);
  12. }
  13. // https://vitejs.dev/config/
  14. // https://github.com/vitejs/vite/issues/1930 .env
  15. const proxyUrl = 'https://test.dayaedu.com/';
  16. export default defineConfig({
  17. base: './',
  18. plugins: [
  19. legacy({
  20. targets: 'last 2 versions and not dead, > 0.3%, Firefox ESR'
  21. }),
  22. vue(),
  23. vueJsx(),
  24. viteESLint(),
  25. Components({
  26. resolvers: [VantResolver()]
  27. })
  28. ],
  29. resolve: {
  30. alias: {
  31. '@': resolve('./src'),
  32. '@common': resolve('./src/common'),
  33. '@components': resolve('./src/components'),
  34. '@store': resolve('./src/store'),
  35. '@views': resolve('./src/views')
  36. }
  37. },
  38. server: {
  39. host: '0.0.0.0',
  40. port: 9002,
  41. strictPort: true,
  42. cors: true,
  43. https: false,
  44. proxy: {
  45. '/api-auth': {
  46. target: proxyUrl,
  47. changeOrigin: true
  48. },
  49. '/api-web': {
  50. target: proxyUrl,
  51. changeOrigin: true
  52. },
  53. '/api-teacher': {
  54. target: proxyUrl,
  55. changeOrigin: true
  56. },
  57. '/api-student': {
  58. target: proxyUrl,
  59. changeOrigin: true
  60. }
  61. }
  62. }
  63. });