vite.config.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { fileURLToPath, URL } from "node:url";
  2. import { defineConfig, splitVendorChunkPlugin } from "vite";
  3. import vue from "@vitejs/plugin-vue";
  4. import Icons from "unplugin-icons/vite";
  5. import IconsResolver from "unplugin-icons/resolver";
  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 ({ mode }) =>
  11. defineConfig({
  12. plugins: [
  13. vue(),
  14. splitVendorChunkPlugin(), // index vendor打包
  15. AutoImport({
  16. imports: ["vue", "vue-router", "pinia"],
  17. include: [/\.[tj]sx?$/, /\.vue$/, /\.vue\?vue/, /\.md$/],
  18. dirs: ["src/components", "src/store"],
  19. eslintrc: {
  20. enabled: true,
  21. },
  22. resolvers: [
  23. ElementPlusResolver(),
  24. IconsResolver({
  25. prefix: "Icon",
  26. }),
  27. ],
  28. dts: "./src/auto-imports.d.ts",
  29. }),
  30. Components({
  31. resolvers: [
  32. ElementPlusResolver(),
  33. IconsResolver({
  34. enabledCollections: ["ep"],
  35. }),
  36. ],
  37. dts: "./src/components.d.ts",
  38. }),
  39. Icons({
  40. autoInstall: true,
  41. }),
  42. ],
  43. base: mode === "development" ? "/" : "./",
  44. server: {
  45. port: 8080,
  46. },
  47. resolve: {
  48. alias: {
  49. "@": fileURLToPath(new URL("./src", import.meta.url)),
  50. "@api": fileURLToPath(new URL("./src/api", import.meta.url)),
  51. "@utils": fileURLToPath(new URL("./src/utils/", import.meta.url)),
  52. },
  53. },
  54. });