vite.config.js 1022 B

123456789101112131415161718192021222324252627282930313233343536
  1. import * as path from "path";
  2. const resolve = (dir) => path.resolve(__dirname, dir);
  3. import { fileURLToPath, URL } from 'node:url'
  4. import { defineConfig } from 'vite'
  5. import vue from '@vitejs/plugin-vue'
  6. import AutoImport from 'unplugin-auto-import/vite'
  7. import Components from 'unplugin-vue-components/vite'
  8. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  9. // https://vitejs.dev/config/
  10. export default defineConfig({
  11. plugins: [vue(), AutoImport({
  12. resolvers: [ElementPlusResolver()],
  13. }),
  14. Components({
  15. resolvers: [ElementPlusResolver()],
  16. }),],
  17. base:'./',
  18. publicDir: resolve('static'),
  19. resolve: {
  20. alias: {
  21. '@': fileURLToPath(new URL('./src', import.meta.url))
  22. }
  23. },
  24. server: {
  25. proxy: {
  26. "/api": {
  27. target: "http://10.90.7.241:9443/data-business-prod", // 所要代理的目标地址
  28. changeOrigin: true, //允许跨域
  29. rewrite: (path) => path.replace(/^\/api/, ""), // 重写传过来的path路径
  30. },
  31. },
  32. }
  33. })