SCSS function

I have inherited some code which includes a function that looks like it should work to me.
// rem units
@function rem($px, $base: $base) {
@return math.div($px, $base) * 1rem;
}
// rem units
@function rem($px, $base: $base) {
@return math.div($px, $base) * 1rem;
}
Whilst trying to process this with node-sass as its an old project. I get this error message returned.
"message": "Invalid CSS after \"... @return math\": expected expression (e.g. 1px, bold), was \".div($px, $base) * \"",
"formatted": "Error: Invalid CSS after \"... @return math\": expected expression (e.g. 1px, bold), was \".div($px, $base) * \"\n on line 43 of src/scss/utils/_utils.scss\n from line 3 of src/scss/screen.scss\n>> @return math.div($px, $base) * 1rem;\n\n ----------------^\n"
"message": "Invalid CSS after \"... @return math\": expected expression (e.g. 1px, bold), was \".div($px, $base) * \"",
"formatted": "Error: Invalid CSS after \"... @return math\": expected expression (e.g. 1px, bold), was \".div($px, $base) * \"\n on line 43 of src/scss/utils/_utils.scss\n from line 3 of src/scss/screen.scss\n>> @return math.div($px, $base) * 1rem;\n\n ----------------^\n"
2 Replies
b1mind
b1mind2y ago
You need to use Dart Sass not Node Sass npm i -D sass probably xD node-sass is deprecated, its a good idea anyway https://sass-lang.com/documentation/modules/math#div
Grant
GrantOP2y ago
Didn't really want to have to rewrite the scss base
Want results from more Discord servers?
Add your server