Node-sass: font-size: max(vw, px) causes internal error

Created on 11 Jan 2020  路  3Comments  路  Source: sass/node-sass

  • NPM version (npm -v): 6.4.1
  • Node version (node -v): v10.10.0
  • Node Process (node -p process.versions):
  • Node Platform (node -p process.platform): darwin
  • Node architecture (node -p process.arch): x64
  • node-sass version (node -p "require('node-sass').info"):
node-sass   4.13.0  (Wrapper)   [JavaScript]
libsass     3.5.4   (Sass Compiler) [C/C++]

Repro CSS:

h1 { font-size: max(1vw, 20px); }

Error:

[0] {
[0]   "status": 3,
[0]   "message": "Incompatible units: 'vw' and 'px'.",
[0]   "formatted": "Internal Error: Incompatible units: 'vw' and 'px'.\n"
[0] }

It seems legit CSS according to https://developer.mozilla.org/en-US/docs/Web/CSS/max

External - LibSass

Most helpful comment

Ahh I see.
For posterity, it seems that also calc(max(1vw, 20px)) works.
Closing as a workaround is available (maybe the error message could give some better clues though)

All 3 comments

This is only supported in dart-sass https://sass-lang.com/documentation/syntax/special-functions#min-and-max
You need to use string interpolation (similar to CSS variables) for this to work outside of dart-sass

h1 { font-size: #{"max(1vw, 20px)"}}; 

Ahh I see.
For posterity, it seems that also calc(max(1vw, 20px)) works.
Closing as a workaround is available (maybe the error message could give some better clues though)

Ahh I see.
For posterity, it seems that also calc(max(1vw, 20px)) works.
Closing as a workaround is available (maybe the error message could give some better clues though)

thank you

Was this page helpful?
0 / 5 - 0 ratings