songsiqi / px2rem

According to one stylesheet, generate rem version and @1x, @2x and @3x stylesheet.
558 stars 92 forks source link

add regExp match value start with point, e.g .5px #43

Open kitty-sheldon opened 3 years ago

kitty-sheldon commented 3 years ago

fix value start with point match error for example .5px was used 5 to transfer to rem

suxuelengyin commented 3 years ago

我也遇到了同样的问题,本想提个PULL,但是作者已经失踪了

tangxiangmin commented 2 years ago

如果是使用dart-sass的压缩模式,会自动将0.5px转成.5px,可以通过修改outputStyle临时处理一下

sassOptions: {
  outputStyle: 'expanded'
}

px2rem里面的var pxRegExp = /\b(\d+(\.\d+)?)px\b/;这个正则确实有点问题,无法正确处理.5px这种字符

tangxiangmin commented 2 years ago

感觉这个commit里面的正则也不太对,用来处理 .5px 10px .55px时也无法正确解析

可以尝试下面这个,

var pxRegExp = /(?<=^|\s+|\b)(\d*\.?\d*)px\b/;