cuth / postcss-pxtorem

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

Better solution to ignore properties #59

Open jpt opened 4 years ago

jpt commented 4 years ago

I appreciate the mention of a workaround in the docs but I wonder if something like this would be a better pattern, similar to the behavior used by eslint (i.e. with a comment):

Input:

h1 {
  font-size: 48px;
}
h2 {
  /* pxtorem-disable-next-line */
  font-size: 24px;
}

Output:

h1 {
  font-size: 3rem;
}
h2 {
  font-size: 24px;
}

I haven't looked at the source yet to see what kind of lift this would be, but would you accept a PR with this kind of solution?

Cheers, and thanks for the great library Jeremy

cuth commented 4 years ago

Yeah. Love the solution!

freesh commented 2 years ago

A similar solution could also be used for forcing the transformation of custom properties:

:root {
  /* pxtorem-transform */
  --font-size-h1: 24px;
}