Open rickbergmann opened 8 months ago
After some further testing and investigation, I initially thought that the Sass compiler had an issue with the 2 similarly named functions _font-url
and font-url
, but when I had renamed them both to _font-urls
and font-urls
the compile was still successful, so I ruled out that theory.
I looked a bit into the Sass compiler (Dart Sass, not Lib Sass), and it will throw this "Invalid function name" error if a reserved word is used as a function name, and the string url
is included in that list, which is really strange because font-url
does not throw an error but _font-url
does.
I then used this online scss compiler (Dart Sass) to test the validity of function names and I found that when a function is prefixed with an underscore and contains a reserved word it throws the "Invalid function name" error. https://json2csharp.com/css-tools/scss-to-css
Some combinations I tried:
@function _font-url : Fails
@function _font-path : Passes
@function font-url : Passes
@function _font-and : Fails
@function _font-or : Fails
This could be a bug in the Dart Sass compiler, not sure if it's intended behavior.
As an interim solution I have submitted a PR and renamed the _font-url
function to _font-path
which will at least prevent the error from occurring during a build process.
I didn't see any differences in the outcomes, but here's the code in the official Sass Playground.
Using the following tech stack:
Node 18.19.0 Webpack 5.89.0 Sass 1.70.0 Sass-loader 14.0.0
I am getting this error during the webpack build:
As a quick test I renamed the function to
_font-urls
which has fixed the error, but I don't understand why the function name is invalid. Any idea's?