vite.config.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.lexiaoya.cn/';
  16. // const proxyUrl = 'http://192.168.3.143:7989/';
  17. export default defineConfig({
  18. base: './',
  19. plugins: [
  20. legacy({
  21. targets: 'last 2 versions and not dead, > 0.3%, Firefox ESR'
  22. }),
  23. vue(),
  24. vueJsx(),
  25. viteESLint(),
  26. Components({
  27. resolvers: [VantResolver()]
  28. })
  29. ],
  30. resolve: {
  31. alias: {
  32. '@': resolve('./src'),
  33. '@common': resolve('./src/common'),
  34. '@components': resolve('./src/components'),
  35. '@store': resolve('./src/store'),
  36. '@views': resolve('./src/views')
  37. }
  38. },
  39. server: {
  40. host: '0.0.0.0',
  41. port: 9002,
  42. strictPort: true,
  43. cors: true,
  44. https: false,
  45. proxy: {
  46. '/edu-oauth': {
  47. target: proxyUrl,
  48. changeOrigin: true
  49. },
  50. '/edu-app': {
  51. target: proxyUrl,
  52. changeOrigin: true
  53. }
  54. }
  55. }
  56. });