vite.config.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { defineConfig, loadEnv } from "vite";
  2. import vue from "@vitejs/plugin-vue";
  3. import path from "path";
  4. import Components from "unplugin-vue-components/vite";
  5. import AutoImport from "unplugin-auto-import/vite";
  6. import { VantResolver } from "unplugin-vue-components/resolvers";
  7. import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
  8. export default ({ mode }) =>
  9. defineConfig({
  10. // base: loadEnv(mode, process.cwd()).VITE_APP_BASE_URL,
  11. plugins: [
  12. vue(),
  13. AutoImport({
  14. resolvers: [ElementPlusResolver()],
  15. }),
  16. Components({
  17. resolvers: [VantResolver(), ElementPlusResolver()],
  18. }),
  19. ],
  20. resolve: {
  21. alias: {
  22. "@": path.resolve(__dirname, "./src"),
  23. },
  24. },
  25. server: {
  26. port: 8888,
  27. cors: true,
  28. host: "0.0.0.0",
  29. proxy: {
  30. "/api": {
  31. target: loadEnv(mode, process.cwd()).VITE_APP_MFYX_BASEAPIURL,
  32. //target: 'https://cygxpctest.hzinsights.com',
  33. changeOrigin: true,
  34. rewrite: (path) => path.replace(/^\/api/, "/api"),
  35. },
  36. },
  37. },
  38. build: {
  39. outDir: loadEnv(mode, process.cwd()).VITE_APP_OUTDIR,
  40. },
  41. });