邃芒慧语、照片说话(PC) https://photo.metavatar.cc/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

103 lines
3.3 KiB

  1. import vue from "@vitejs/plugin-vue";
  2. import { UserConfig, ConfigEnv, loadEnv, defineConfig } from "vite";
  3. import AutoImport from "unplugin-auto-import/vite";
  4. import Components from "unplugin-vue-components/vite";
  5. import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
  6. import Icons from "unplugin-icons/vite";
  7. import IconsResolver from "unplugin-icons/resolver";
  8. import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
  9. import UnoCSS from "unocss/vite";
  10. import path from "path";
  11. const pathSrc = path.resolve(__dirname, "src");
  12. export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
  13. const env = loadEnv(mode, process.cwd());
  14. return {
  15. resolve: {
  16. alias: {
  17. "@": pathSrc,
  18. },
  19. },
  20. css: {
  21. // CSS 预处理器
  22. preprocessorOptions: {
  23. //define global scss variable
  24. scss: {
  25. javascriptEnabled: true,
  26. additionalData: `
  27. @use "@/styles/variables.scss" as *;
  28. `,
  29. },
  30. },
  31. },
  32. server: {
  33. host: "0.0.0.0",
  34. port: Number(env.VITE_APP_PORT),
  35. open: true, // 运行是否自动打开浏览器
  36. proxy: {
  37. // 反向代理解决跨域
  38. [env.VITE_APP_BASE_API]: {
  39. target: "http://vapi.youlai.tech", // 线上接口地址
  40. // target: 'http://localhost:8989', // 本地接口地址
  41. changeOrigin: true,
  42. rewrite: (path) =>
  43. path.replace(new RegExp("^" + env.VITE_APP_BASE_API), ""), // 替换 /dev-api 为 target 接口地址
  44. },
  45. },
  46. },
  47. plugins: [
  48. vue(),
  49. UnoCSS({
  50. /* options */
  51. }),
  52. AutoImport({
  53. // 自动导入 Vue 相关函数,如:ref, reactive, toRef 等
  54. imports: ["vue", "@vueuse/core"],
  55. // eslintrc: {
  56. // enabled: false, // Default `false`
  57. // filepath: "./.eslintrc-auto-import.json", // Default `./.eslintrc-auto-import.json`
  58. // globalsPropValue: true, // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
  59. // },
  60. resolvers: [
  61. // 自动导入 Element Plus 相关函数,如:ElMessage, ElMessageBox... (带样式)
  62. ElementPlusResolver(),
  63. // 自动导入图标组件
  64. IconsResolver({}),
  65. ],
  66. vueTemplate: true, // 是否在 vue 模板中自动导入
  67. dts: path.resolve(pathSrc, "types", "auto-imports.d.ts"), // 自动导入组件类型声明文件位置,默认根目录; false 关闭自动生成
  68. }),
  69. Components({
  70. resolvers: [
  71. // 自动注册图标组件
  72. IconsResolver({
  73. enabledCollections: ["ep"], //@iconify-json/ep 是 Element Plus 的图标库
  74. }),
  75. // 自动导入 Element Plus 组件
  76. ElementPlusResolver(),
  77. ],
  78. dts: path.resolve(pathSrc, "types", "components.d.ts"), // 自动导入组件类型声明文件位置,默认根目录; false 关闭自动生成
  79. }),
  80. Icons({
  81. // 自动安装图标库
  82. autoInstall: true,
  83. }),
  84. createSvgIconsPlugin({
  85. // 指定需要缓存的图标文件夹
  86. iconDirs: [path.resolve(pathSrc, "assets/icons")],
  87. // 指定symbolId格式
  88. symbolId: "icon-[dir]-[name]",
  89. }),
  90. ],
  91. };
  92. });