邃芒慧语、照片说话(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.
 
 
 
 
 

104 regels
3.1 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. "/api": {
  39. target: env.VITE_APP_BASE_API, // 线上接口地址
  40. changeOrigin: true,
  41. rewrite: (path) => path.replace(/^\/api/, ""),
  42. },
  43. },
  44. },
  45. plugins: [
  46. vue(),
  47. UnoCSS({
  48. /* options */
  49. }),
  50. AutoImport({
  51. // 自动导入 Vue 相关函数,如:ref, reactive, toRef 等
  52. imports: ["vue", "@vueuse/core"],
  53. // eslintrc: {
  54. // enabled: false, // Default `false`
  55. // filepath: "./.eslintrc-auto-import.json", // Default `./.eslintrc-auto-import.json`
  56. // globalsPropValue: true, // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
  57. // },
  58. resolvers: [
  59. // 自动导入 Element Plus 相关函数,如:ElMessage, ElMessageBox... (带样式)
  60. ElementPlusResolver(),
  61. // 自动导入图标组件
  62. IconsResolver({}),
  63. ],
  64. vueTemplate: true, // 是否在 vue 模板中自动导入
  65. dts: path.resolve(pathSrc, "types", "auto-imports.d.ts"), // 自动导入组件类型声明文件位置,默认根目录; false 关闭自动生成
  66. }),
  67. Components({
  68. resolvers: [
  69. // 自动注册图标组件
  70. IconsResolver({
  71. enabledCollections: ["ep"], //@iconify-json/ep 是 Element Plus 的图标库
  72. }),
  73. // 自动导入 Element Plus 组件
  74. ElementPlusResolver(),
  75. ],
  76. dts: path.resolve(pathSrc, "types", "components.d.ts"), // 自动导入组件类型声明文件位置,默认根目录; false 关闭自动生成
  77. }),
  78. Icons({
  79. // 自动安装图标库
  80. autoInstall: true,
  81. }),
  82. createSvgIconsPlugin({
  83. // 指定需要缓存的图标文件夹
  84. iconDirs: [path.resolve(pathSrc, "assets/icons")],
  85. // 指定symbolId格式
  86. symbolId: "icon-[dir]-[name]",
  87. }),
  88. ],
  89. // define: {
  90. // global: {},
  91. // },
  92. };
  93. });