postcss / postcss-mixins

PostCSS plugin for mixins
MIT License
466 stars 47 forks source link

could I write a mixin for the values with postcss-mixin? #138

Closed budarin closed 2 years ago

budarin commented 2 years ago

We need to have an ability to convert pixels to rem Is there an ability to write mixin for values like this

.some-selector {
  ...
  width: $rem(50);
  ...
}

to produce

.some-selector {
  ...
  width: 3.125rem;
  ...
}
ai commented 2 years ago

Please. Do not use issues (bug reports) for the questions.

Nope. postcss-mixins can’t be used to create functions. There are postcss-functions for that.

But I do not recommend to copy Sass patterns. PostCSS way is to keep clean and simple CSS code and move all logic to JS-based PostCSS plugins.

There are a few PostCSS plugins to convert with: 50px to rem with a way to block convertation by comments or selectors.

budarin commented 2 years ago

thanks!