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

125 line
4.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 postCssPxToRem from 'postcss-pxtorem'
  10. import UnoCSS from "unocss/vite";
  11. import path from "path";
  12. const pathSrc = path.resolve(__dirname, "src");
  13. export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
  14. const env = loadEnv(mode, process.cwd());
  15. return {
  16. resolve: {
  17. alias: {
  18. "@": pathSrc,
  19. 'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js'
  20. },
  21. },
  22. css: {
  23. // CSS 预处理器
  24. preprocessorOptions: {
  25. //define global scss variable
  26. scss: {
  27. javascriptEnabled: true,
  28. additionalData: `
  29. @use "@/styles/variables.scss" as *;
  30. `,
  31. },
  32. },
  33. postcss: {
  34. plugins: [
  35. postCssPxToRem({
  36. rootValue: 192, // 1rem 的大小
  37. propList: ['*'], // 需要转换的属性,*(全部转换)
  38. unitPrecision: 6 // 转换精度,保留的小数位数
  39. })
  40. ]
  41. }
  42. },
  43. server: {
  44. host: "0.0.0.0",
  45. port: Number(env.VITE_APP_PORT),
  46. open: true, // 运行是否自动打开浏览器
  47. proxy: {
  48. // 反向代理解决跨域
  49. "/api": {
  50. // target: https://phototest.metavatar.cc/C, // 线上接口地址
  51. target: env.VITE_APP_BASE_API, // 线上接口地址
  52. changeOrigin: true,
  53. rewrite: (path) => path.replace(/^\/api/, ""),
  54. },
  55. // "/C/api/suimang": {
  56. // target:'https://phototest.metavatar.cc/', // 线上接口地址
  57. // changeOrigin: true,
  58. // rewrite: (path) => path.replace(/^\/C\/api\/suimang/, '/suimang/image_qualit')
  59. // },
  60. // "/api/suimang": {
  61. // target:'https://phototest.metavatar.cc/', // 线上接口地址
  62. // changeOrigin: true,
  63. // rewrite: (path) => path.replace(/^\/api\/suimang/, '/suimang/image_qualit')
  64. // },
  65. },
  66. },
  67. plugins: [
  68. vue(),
  69. UnoCSS({
  70. /* options */
  71. }),
  72. AutoImport({
  73. // 自动导入 Vue 相关函数,如:ref, reactive, toRef 等
  74. imports: ["vue", "@vueuse/core"],
  75. // eslintrc: {
  76. // enabled: false, // Default `false`
  77. // filepath: "./.eslintrc-auto-import.json", // Default `./.eslintrc-auto-import.json`
  78. // globalsPropValue: true, // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
  79. // },
  80. resolvers: [
  81. // 自动导入 Element Plus 相关函数,如:ElMessage, ElMessageBox... (带样式)
  82. ElementPlusResolver(),
  83. // 自动导入图标组件
  84. IconsResolver({}),
  85. ],
  86. vueTemplate: true, // 是否在 vue 模板中自动导入
  87. dts: path.resolve(pathSrc, "types", "auto-imports.d.ts"), // 自动导入组件类型声明文件位置,默认根目录; false 关闭自动生成
  88. }),
  89. Components({
  90. resolvers: [
  91. // 自动注册图标组件
  92. IconsResolver({
  93. enabledCollections: ["ep"], //@iconify-json/ep 是 Element Plus 的图标库
  94. }),
  95. // 自动导入 Element Plus 组件
  96. ElementPlusResolver(),
  97. ],
  98. dts: path.resolve(pathSrc, "types", "components.d.ts"), // 自动导入组件类型声明文件位置,默认根目录; false 关闭自动生成
  99. }),
  100. Icons({
  101. // 自动安装图标库
  102. autoInstall: true,
  103. }),
  104. createSvgIconsPlugin({
  105. // 指定需要缓存的图标文件夹
  106. iconDirs: [path.resolve(pathSrc, "assets/icons")],
  107. // 指定symbolId格式
  108. symbolId: "icon-[dir]-[name]",
  109. }),
  110. ],
  111. // define: {
  112. // global: {},
  113. // },
  114. };
  115. });