邃芒慧影、口播(PC) https://neuver.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.

пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 postCssPxToRem from 'postcss-pxtorem'
  9. import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
  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. },
  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. postcss: {
  33. plugins: [
  34. postCssPxToRem({
  35. rootValue: 192, // 1rem 的大小
  36. propList: ['*'], // 需要转换的属性,*(全部转换)
  37. unitPrecision: 6 // 转换精度,保留的小数位数
  38. })
  39. ]
  40. }
  41. },
  42. server: {
  43. host: "0.0.0.0",
  44. port: Number(env.VITE_APP_PORT),
  45. open: true, // 运行是否自动打开浏览器
  46. proxy: {
  47. // 反向代理解决跨域
  48. "/api": {
  49. target: env.VITE_APP_BASE_API, // 线上接口地址
  50. changeOrigin: true,
  51. rewrite: (path) => path.replace(/^\/api/, ""),
  52. },
  53. },
  54. },
  55. plugins: [
  56. vue(),
  57. UnoCSS({
  58. /* options */
  59. }),
  60. AutoImport({
  61. // 自动导入 Vue 相关函数,如:ref, reactive, toRef 等
  62. imports: ["vue", "@vueuse/core"],
  63. // eslintrc: {
  64. // enabled: false, // Default `false`
  65. // filepath: "./.eslintrc-auto-import.json", // Default `./.eslintrc-auto-import.json`
  66. // globalsPropValue: true, // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
  67. // },
  68. resolvers: [
  69. // 自动导入 Element Plus 相关函数,如:ElMessage, ElMessageBox... (带样式)
  70. ElementPlusResolver(),
  71. // 自动导入图标组件
  72. IconsResolver({}),
  73. ],
  74. vueTemplate: true, // 是否在 vue 模板中自动导入
  75. dts: path.resolve(pathSrc, "types", "auto-imports.d.ts"), // 自动导入组件类型声明文件位置,默认根目录; false 关闭自动生成
  76. }),
  77. Components({
  78. resolvers: [
  79. // 自动注册图标组件
  80. IconsResolver({
  81. enabledCollections: ["ep"], //@iconify-json/ep 是 Element Plus 的图标库
  82. }),
  83. // 自动导入 Element Plus 组件
  84. ElementPlusResolver(),
  85. ],
  86. dts: path.resolve(pathSrc, "types", "components.d.ts"), // 自动导入组件类型声明文件位置,默认根目录; false 关闭自动生成
  87. }),
  88. Icons({
  89. // 自动安装图标库
  90. autoInstall: true,
  91. }),
  92. createSvgIconsPlugin({
  93. // 指定需要缓存的图标文件夹
  94. iconDirs: [path.resolve(pathSrc, "assets/icons")],
  95. // 指定symbolId格式
  96. symbolId: "icon-[dir]-[name]",
  97. }),
  98. ],
  99. // define: {
  100. // global: {},
  101. // },
  102. };
  103. });