Showing
1 changed file
with
20 additions
and
1 deletions
| ... | @@ -6,6 +6,7 @@ import { defineConfig, loadEnv } from 'vite'; | ... | @@ -6,6 +6,7 @@ import { defineConfig, loadEnv } from 'vite'; |
| 6 | import { createProxy } from './build/proxy' | 6 | import { createProxy } from './build/proxy' |
| 7 | import DefineOptions from 'unplugin-vue-define-options/vite'; | 7 | import DefineOptions from 'unplugin-vue-define-options/vite'; |
| 8 | import AutoImport from 'unplugin-auto-import/vite'; | 8 | import AutoImport from 'unplugin-auto-import/vite'; |
| 9 | +import postcsspxtoviewport from 'postcss-px-to-viewport' | ||
| 9 | 10 | ||
| 10 | var path = require('path'); | 11 | var path = require('path'); |
| 11 | 12 | ||
| ... | @@ -69,7 +70,25 @@ export default ({ command, mode }) => { | ... | @@ -69,7 +70,25 @@ export default ({ command, mode }) => { |
| 69 | }, | 70 | }, |
| 70 | css: { | 71 | css: { |
| 71 | modules: '', // 配置 CSS modules 的行为。选项将被传递给 postcss-modules。 | 72 | modules: '', // 配置 CSS modules 的行为。选项将被传递给 postcss-modules。 |
| 72 | - postcss: '', // 内联的 PostCSS 配置(格式同 postcss.config.js),或者一个(默认基于项目根目录的)自定义的 PostCSS 配置路径。其路径搜索是通过 postcss-load-config 实现的。 注意,如果提供了该内联配置,Vite 将不会搜索其他 PostCSS 配置源。 | 73 | + postcss: { // 内联的 PostCSS 配置(格式同 postcss.config.js),或者一个(默认基于项目根目录的)自定义的 PostCSS 配置路径。其路径搜索是通过 postcss-load-config 实现的。 注意,如果提供了该内联配置,Vite 将不会搜索其他 PostCSS 配置源。 |
| 74 | + plugins: [ | ||
| 75 | + postcsspxtoviewport({ | ||
| 76 | + unitToConvert: 'px', // 要转化的单位 | ||
| 77 | + viewportWidth: 375, // UI设计稿的宽度 | ||
| 78 | + unitPrecision: 6, // 转换后的精度,即小数点位数 | ||
| 79 | + propList: ['*'], // 指定转换的css属性的单位,*代表全部css属性的单位都进行转换 | ||
| 80 | + viewportUnit: 'vw', // 指定需要转换成的视窗单位,默认vw | ||
| 81 | + fontViewportUnit: 'vw', // 指定字体需要转换成的视窗单位,默认vw | ||
| 82 | + selectorBlackList: ['ignore-'], // 指定不转换为视窗单位的类名, | ||
| 83 | + minPixelValue: 1, // 默认值1,小于或等于1px则不进行转换 | ||
| 84 | + mediaQuery: true, // 是否在媒体查询的css代码中也进行转换,默认false | ||
| 85 | + replace: true, // 是否转换后直接更换属性值 | ||
| 86 | + // exclude: [/node_modules/], // 设置忽略文件,用正则做目录名匹配 | ||
| 87 | + exclude: [], | ||
| 88 | + landscape: false // 是否处理横屏情况 | ||
| 89 | + }) | ||
| 90 | + ] | ||
| 91 | + }, | ||
| 73 | preprocessorOptions: { | 92 | preprocessorOptions: { |
| 74 | less: { | 93 | less: { |
| 75 | javascriptEnabled: true, | 94 | javascriptEnabled: true, | ... | ... |
-
Please register or login to post a comment