cuth / postcss-pxtorem

Convert pixel units to rem (root em) units using PostCSS
MIT License
2.03k stars 174 forks source link

PX/Px being converted to rem when inside calc() #34

Closed mattmccarley closed 7 years ago

mattmccarley commented 7 years ago

I need a pixel value to remain a pixel value inside of a calc function. I have made sure that the value is -17.4359PX before the postcss-pxtorem processes. After processing, this is converted to -1.08974rem.

Is there a specific reason by the plugin ignores PX/Px inside of a calc()?

Is there a workaround?

cuth commented 7 years ago

I added a test for the case-sensitivity of px and included calc() in #35. I didn't seem to have the same issue that you are having.

cuth commented 7 years ago

Do you have a pre-processor running on your CSS before it gets to postcss? Maybe something is converting the PX to px.

mattmccarley commented 7 years ago

After some further testing, it appears that the following example causes the issue: margin: 12px calc(12PX + 2PX) In this example the 2 upper case pixel values get converted to rems.

cuth commented 7 years ago

@mdmccarley89 Nevermind, you are correct. I think I know the issue too. I'll put out a fix soon.

cuth commented 7 years ago

@mdmccarley89 published postcss-pxtorem@4.0.1

mattmccarley commented 7 years ago

Thanks so much Jonathan!