question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Significant line height differences between node-sass and dart-sass

See original GitHub issue

Rendering the govuk-frontend scss with dart-sass results in surprisingly significant line height differences when compared to node-sass. This is caused by the default precision of dart-sass being 10, whereas it is 5 in node-sass. The problematic code lies here, in the calculation of line height.

  @if not unitless($line-height) and unit($line-height) == unit($font-size) {
    $line-height: $line-height / $font-size;
  }

  @return $line-height;
}

This is a screenshot of the differences registered by backstop (In this case, from nhsuk-frontend, but it’s the same line height code).

image

Over on nhsuk-frontend, we are now forcibly rounding to 5 decimal places so that we get consistent rendering across node-sass and dart-sass (Sounds minor, but people are likely to be hopping between different bits of the NHS regularly so as much consistency as possible is nice). I will open a pull request shortly with our solution, for discussion…

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
36degreescommented, Jul 5, 2021

Not at all, it was definitely worth investigating (and interesting 🤓 )! Really do appreciate you taking the time to share your findings with us.

0reactions
36degreescommented, Sep 24, 2021

I think the things we need to do to resolve this are:

  • change the precision in our own build pipeline to 6dp (unless we’ve already done #2239 which’ll force us to 10dp anyway)
  • document the precision somewhere, for anyone using node-sass or Ruby Sass (but accept that teams are likely to miss it)

I’ve also noticed a separate but related issue with the grid which I’ve written up in #2361, and which we should do at the same time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node-Sass or Dart-Sass : The CSS Preprocessor Dilemma
In our test scenario, Dart-Sass(On DartVM) is the fastest, node-sass isn't that bad, and Dart-Sass(Pure JS) is terrible in terms of performance.
Read more >
Dart Sass Command-Line Interface
Many-to-many mode compiles one or more input files to one or more output files. The inputs are separated from the outputs with colons....
Read more >
Option to use the DartVM executable rather than the pure-js ...
Currently, the only options for implementation are node-sass and the pure-js version of dart-sass. There should be an option to use the fast ......
Read more >
Quick comparison between sass and node-sass - Peterbe.com
Considering that sass is just a JavaScript compilation of a Dart program, all you get is basically a 3.6MB node_modules/sass/sass.dart.js file.
Read more >
Any way to change precision in node-sass / libsass
It currently rounds to 5, but if I need to give a line-height which is a recurring number i.e 1.33333 I get minor...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found