vite.config.js 975 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { defineConfig } from 'vite';
  2. import vue from '@vitejs/plugin-vue';
  3. import path from 'path';
  4. import { fileURLToPath } from 'url';
  5. import AutoImport from 'unplugin-auto-import/vite'
  6. import Components from 'unplugin-vue-components/vite'
  7. // import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  8. // 获取当前文件的目录名
  9. const __filename = fileURLToPath(import.meta.url);
  10. const __dirname = path.dirname(__filename);
  11. export default defineConfig({
  12. plugins: [vue(),
  13. // AutoImport({
  14. // resolvers: [ElementPlusResolver()],
  15. // }),
  16. // Components({
  17. // resolvers: [ElementPlusResolver()],
  18. // }),
  19. ],
  20. resolve: {
  21. alias: {
  22. '@': path.resolve(__dirname, './src'),
  23. },
  24. },
  25. server: {
  26. proxy: {
  27. '/api': {
  28. // target: 'http://10.113.233.180:8080',
  29. target: 'http://localhost:8080',
  30. changeOrigin: true,
  31. rewrite: (path) => path.replace(/^\/api/, '')
  32. }
  33. }
  34. }
  35. });