vite.config.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import { fileURLToPath, URL } from "node:url";
  2. import { defineConfig } 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 defineConfig(({ mode }) => {
  11. return {
  12. plugins: [
  13. vue(),
  14. AutoImport({
  15. imports: ["vue", "vue-router", "pinia"],
  16. include: [/\.[tj]sx?$/, /\.vue$/, /\.vue\?vue/],
  17. dirs: ["src/components", "src/store", "*.d.ts"],
  18. eslintrc: {
  19. //enabled: true,
  20. },
  21. resolvers: [
  22. ElementPlusResolver(),
  23. IconsResolver({
  24. prefix: "Icon",
  25. }),
  26. ],
  27. dts: "./src/auto-imports.d.ts",
  28. }),
  29. Components({
  30. resolvers: [
  31. ElementPlusResolver(),
  32. IconsResolver({
  33. enabledCollections: ["ep"],
  34. }),
  35. ],
  36. dts: "./src/components.d.ts",
  37. }),
  38. Icons({
  39. autoInstall: true,
  40. }),
  41. ],
  42. base: mode === "development" ? "/" : "./",
  43. server: {
  44. port: 8080,
  45. },
  46. resolve: {
  47. alias: {
  48. "@": fileURLToPath(new URL("./src", import.meta.url)),
  49. "@api": fileURLToPath(new URL("./src/api", import.meta.url)),
  50. "@utils": fileURLToPath(new URL("./src/utils/", import.meta.url)),
  51. },
  52. },
  53. esbuild: {
  54. drop: mode === "development" ? undefined : ["console", "debugger"],
  55. },
  56. build: {
  57. rollupOptions: {
  58. output: {
  59. manualChunks: (id) => {
  60. if (id.includes("node_modules")) {
  61. return "vendor";
  62. }
  63. },
  64. },
  65. },
  66. },
  67. css: {
  68. preprocessorOptions: {
  69. scss: {
  70. api: 'modern-compiler', // or 'modern'
  71. },
  72. },
  73. },
  74. }
  75. });