Closed maximgatilin closed 8 years ago
@gatilin222 what kind of support?
@borodean I want to convert image sizes to rem units, no pixels.
@gatilin222 I'm suspicions that this kind of a feature is far from the scope of Assets while I would like to keep it as simple as possible. One of the ways to resolve this would be using some of the existing Postcss plugins or developing your own one covering this need.
@gatilin222 for instance, this is how I would solve this using postcss-functions
:
require('postcss-functions')({
functions: {
// Convert pixels to rems
// eg. for a relational value of 12px write rem(12)
// Assumes emBase is the font-size of <html>, defaults to 16px
rem: function (pxValue, emBase) {
pxValue = parseInt(pxValue, 10);
emBase = emBase ? parseInt(emBase, 10) : 16;
return pxValue / emBase + 'rem';
}
}
});
.foobar {
width: rem(width('foobar.png'));
}
It would be awesome to add rem support to plugin