vite.config.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 = 'https://dev.kt.colexiu.com/';
  17. const proxyUrl = 'http://192.168.3.143:7989/';
  18. export default defineConfig({
  19. base: './',
  20. plugins: [
  21. legacy({
  22. targets: ['> 0.25%, not dead'],
  23. ignoreBrowserslistConfig: true
  24. }),
  25. vue(),
  26. vueJsx(),
  27. viteESLint(),
  28. Components({
  29. resolvers: [VantResolver()]
  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: 9002,
  44. strictPort: true,
  45. cors: true,
  46. https: false,
  47. proxy: {
  48. '/edu-app': {
  49. target: proxyUrl,
  50. changeOrigin: true
  51. }
  52. }
  53. }
  54. });