vite.config.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { fileURLToPath, URL } from "node:url";
  2. import { defineConfig } from "vite";
  3. import vue from "@vitejs/plugin-vue";
  4. import vueJsx from "@vitejs/plugin-vue-jsx";
  5. import Components from "unplugin-vue-components/vite";
  6. import { VantResolver } from "unplugin-vue-components/resolvers";
  7. import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
  8. import path from "path";
  9. import AutoImport from "unplugin-auto-import/vite";
  10. import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
  11. // https://vitejs.dev/config/
  12. export default defineConfig({
  13. base: "./",
  14. server: {
  15. proxy: {
  16. "/api/tts": {
  17. target: "http://192.168.20.245:8008",
  18. changeOrigin: true,
  19. },
  20. "/api": {
  21. target: "https://sit-shoubov2.4dage.com",
  22. changeOrigin: true,
  23. },
  24. },
  25. },
  26. css: {
  27. preprocessorOptions: {
  28. scss: {
  29. additionalData: `@use "@/assets/css/element.scss" as *;`,
  30. },
  31. },
  32. },
  33. plugins: [
  34. vue(),
  35. vueJsx(),
  36. Components({
  37. resolvers: [VantResolver(), ElementPlusResolver({ importStyle: "sass" })],
  38. }),
  39. AutoImport({
  40. resolvers: [ElementPlusResolver()],
  41. }),
  42. createSvgIconsPlugin({
  43. // 指定需要缓存的图标文件夹
  44. iconDirs: [path.resolve(process.cwd(), "src/assets/svgs")],
  45. // 指定symbolId格式
  46. symbolId: "icon-[dir]-[name]",
  47. }),
  48. ],
  49. resolve: {
  50. alias: {
  51. "@": fileURLToPath(new URL("./src", import.meta.url)),
  52. },
  53. },
  54. });