默认配置会对所有的 px 单位进行转换,有大写字母的 Px 或 PX 则会被忽略。
参数默认值如下:
{onePxTransform: true,unitPrecision: 5,propList: ['*'],selectorBlackList: [],replace: true,mediaQuery: false,minPixelValue: 0}
onePxTransform (Boolean)
unitPrecision (Number)
propList (Array)
允许转换的属性。
- Values need to be exact matches.
 - Use wildcard 
*to enable all properties. Example:['*'] - Use 
*at the start or end of a word. (['*position*']will matchbackground-position-y) - Use 
!to not match a property. Example:['*', '!letter-spacing'] Combine the “not” prefix with the other prefixes. Example:
['*', '!font*']selectorBlackList黑名单里的选择器将会被忽略。
If value is string, it checks to see if selector contains the string.
['body']will match.body-class
- If value is regexp, it checks to see if the selector matches the regexp.
[/^body$/]will matchbodybut not.body
直接替换而不是追加一条进行覆盖。replace(Boolean)
允许媒体查询里的 px 单位转换mediaQuery(Boolean)
设置一个可被转换的最小 px 值minPixelValue(Number)
配置规则对应到config/index.js,例如:{h5: {publicPath: '/',staticDirectory: 'static',postcss: {autoprefixer: {enable: true},pxtransform: {enable: true,config: {selectorBlackList: ['body']}}}},mini: {// ...postcss: {pxtransform: {enable: true,config: {selectorBlackList: ['body']}}}}}
 
