vite.config.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { fileURLToPath, URL } from 'node:url'
  2. import { defineConfig } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import postcsspxtoviewport from 'postcss-px-to-viewport'
  5. // https://vitejs.dev/config/
  6. export default defineConfig({
  7. plugins: [
  8. vue()
  9. ],
  10. build: {
  11. outDir: 'low_altitude_web'
  12. },
  13. resolve: {
  14. alias: {
  15. '@': fileURLToPath(new URL('./src', import.meta.url))
  16. }
  17. },
  18. css: {
  19. preprocessorOptions: {
  20. scss: {
  21. api: "modern-compiler" // or 'modern'
  22. }
  23. },
  24. postcss: {
  25. plugins: [
  26. postcsspxtoviewport({
  27. unitToConvert: "px", // 要转化的单位
  28. viewportWidth: 1080, // UI设计稿的宽度
  29. unitPrecision: 6, // 转换后的精度,即小数点位数
  30. propList: ["*"], // 指定转换的css属性的单位,*代表全部css属性的单位都进行转换
  31. viewportUnit: "vh", // 指定需要转换成的视窗单位,默认vw
  32. fontViewportUnit: "vh", // 指定字体需要转换成的视窗单位,默认vw
  33. selectorBlackList: [], // 指定不转换为视窗单位的类名,
  34. minPixelValue: 1, // 默认值1,小于或等于1px则不进行转换
  35. mediaQuery: true, // 是否在媒体查询的css代码中也进行转换,默认false
  36. replace: true, // 是否转换后直接更换属性值
  37. exclude: [/node_modules/], // 设置忽略文件,用正则做目录名匹配
  38. // include: [/overview_4k/],
  39. landscape: false // 是否处理横屏情况
  40. }),
  41. ]
  42. }
  43. },
  44. base: '/low_altitude/'
  45. })