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

105 lines
3.2 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. 'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js'
  19. },
  20. },
  21. css: {
  22. // CSS 预处理器
  23. preprocessorOptions: {
  24. //define global scss variable
  25. scss: {
  26. javascriptEnabled: true,
  27. additionalData: `
  28. @use "@/styles/variables.scss" as *;
  29. `,
  30. },
  31. },
  32. },
  33. server: {
  34. host: "0.0.0.0",
  35. port: Number(env.VITE_APP_PORT),
  36. open: true, // 运行是否自动打开浏览器
  37. proxy: {
  38. // 反向代理解决跨域
  39. "/api": {
  40. target: env.VITE_APP_BASE_API, // 线上接口地址
  41. changeOrigin: true,
  42. rewrite: (path) => path.replace(/^\/api/, ""),
  43. },
  44. },
  45. },
  46. plugins: [
  47. vue(),
  48. UnoCSS({
  49. /* options */
  50. }),
  51. AutoImport({
  52. // 自动导入 Vue 相关函数,如:ref, reactive, toRef 等
  53. imports: ["vue", "@vueuse/core"],
  54. // eslintrc: {
  55. // enabled: false, // Default `false`
  56. // filepath: "./.eslintrc-auto-import.json", // Default `./.eslintrc-auto-import.json`
  57. // globalsPropValue: true, // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
  58. // },
  59. resolvers: [
  60. // 自动导入 Element Plus 相关函数,如:ElMessage, ElMessageBox... (带样式)
  61. ElementPlusResolver(),
  62. // 自动导入图标组件
  63. IconsResolver({}),
  64. ],
  65. vueTemplate: true, // 是否在 vue 模板中自动导入
  66. dts: path.resolve(pathSrc, "types", "auto-imports.d.ts"), // 自动导入组件类型声明文件位置,默认根目录; false 关闭自动生成
  67. }),
  68. Components({
  69. resolvers: [
  70. // 自动注册图标组件
  71. IconsResolver({
  72. enabledCollections: ["ep"], //@iconify-json/ep 是 Element Plus 的图标库
  73. }),
  74. // 自动导入 Element Plus 组件
  75. ElementPlusResolver(),
  76. ],
  77. dts: path.resolve(pathSrc, "types", "components.d.ts"), // 自动导入组件类型声明文件位置,默认根目录; false 关闭自动生成
  78. }),
  79. Icons({
  80. // 自动安装图标库
  81. autoInstall: true,
  82. }),
  83. createSvgIconsPlugin({
  84. // 指定需要缓存的图标文件夹
  85. iconDirs: [path.resolve(pathSrc, "assets/icons")],
  86. // 指定symbolId格式
  87. symbolId: "icon-[dir]-[name]",
  88. }),
  89. ],
  90. // define: {
  91. // global: {},
  92. // },
  93. };
  94. });