vite.config.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { fileURLToPath, URL } from "node:url";
  2. import { defineConfig } from "vite";
  3. import vue from "@vitejs/plugin-vue";
  4. import AutoImport from "unplugin-auto-import/vite";
  5. import Components from "unplugin-vue-components/vite";
  6. import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
  7. // https://vite.dev/config/
  8. export default defineConfig({
  9. base: "./",
  10. server: {
  11. host: "0.0.0.0",
  12. port: 5175,
  13. },
  14. plugins: [
  15. vue(),
  16. AutoImport({
  17. resolvers: [
  18. ElementPlusResolver({
  19. importStyle: "sass",
  20. }),
  21. ],
  22. }),
  23. Components({
  24. resolvers: [ElementPlusResolver({ importStyle: "sass" })],
  25. }),
  26. ],
  27. resolve: {
  28. alias: {
  29. "@": fileURLToPath(new URL("./src", import.meta.url)),
  30. },
  31. },
  32. css: {
  33. preprocessorOptions: {
  34. scss: {
  35. api: "modern-compiler",
  36. additionalData(source, filename) {
  37. if (filename.replace(/\\/g, "/").endsWith("src/assets/elements.scss")) {
  38. return source;
  39. }
  40. return `@use "@/assets/elements.scss" as *;\n${source}`;
  41. },
  42. },
  43. },
  44. },
  45. });