En esta función compilo rem a px y em a px .
$base: 16 !default; @function scut-strip-unit ($num) { @return $num / ($num * 0 + 1); } @function rem ($pixels) { @return scut-strip-unit($pixels) / $base * 1rem; } @function em ($pixels, $context: $base) { @return #{$pixels/$context}em; }Pero con sass v1.49, nos enfrentamos a este error:
Error Deprecation Warning: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0. Recommendation: math.div(scut-strip-unit($pixels), $base) or calc(scut-strip-unit($pixels) / $base) More info and automated migrator: https://sass-lang.com/d/slash-div ╷ 8 │ @return scut-strip-unit($pixels) / $base * 1rem;Lo que dice es que deberías usar math.div de sass:math para hacer divisiones, así:
@use "sass:math"; @function to-rem($pxNb) { @return math.div($pxNb, 16) * 1rem; }Para evitar usar sass:math, puede usar
calc(scut-strip-unit($pixels) / $base)