sass / node-sass

:rainbow: Node.js bindings to libsass
https://npmjs.org/package/node-sass
MIT License
8.5k stars 1.33k forks source link

SassError when processing CSS variable with url() as contents. #2931

Open 3rd-Eden opened 4 years ago

3rd-Eden commented 4 years ago

I'm trying to compile a sass file that exports various of CSS variables, but during the compilation it throws on the following definition:

:root{--uxp-icon-chevron-up-lt:url("data:image/svg+xml;utf-8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24'><path fill-rule='evenodd' d='M19.39 14.99l-1.41 1.41L12 10.43 6.02 16.4l-1.41-1.41L12 7.6l7.39 7.39z' clip-rule='evenodd'/></svg>");}

When processing that specific file statement with the node-sass (cli used as example here):

node-sass index.scss

You will be receiving the following error:

{
  "status": 1,
  "file": "/lol/yeah/not/sharing/full/path/here/index.scss",
  "line": 1,
  "column": 32,
  "message": "property \"url\" must be followed by a ':'",
  "formatted": "Error: property \"url\" must be followed by a ':'\n        on line 1 of index.scss\n>> :root{--uxp-icon-chevron-up-lt:url(\"data:image/svg+xml;utf-8,<svg xmlns='htt\n   -------------------------------^\n"
}

However when I process it with dart-sass (sass --version outputs: 1.26.7 compiled with dart2js 2.8.2), it works fine, and outputs the following as expected:

:root {
  --uxp-icon-chevron-up-lt:url("data:image/svg+xml;utf-8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24'><path fill-rule='evenodd' d='M19.39 14.99l-1.41 1.41L12 10.43 6.02 16.4l-1.41-1.41L12 7.6l7.39 7.39z' clip-rule='evenodd'/></svg>");
}

Leading me to believe that this is an issue inside node-sass that is preventing it from rending this.

3rd-Eden commented 4 years ago

For those who run into a similar issue as this. This a workaround for said problem, using interpolation of sass variables into a CSS variable completely bypasses the property validation it seems:

:root{
  $example: url("data:image/svg+xml;utf-8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24'><path fill-rule='evenodd' d='M19.39 14.99l-1.41 1.41L12 10.43 6.02 16.4l-1.41-1.41L12 7.6l7.39 7.39z' clip-rule='evenodd'/></svg>");
  --uxp-icon-chevron-up-lt: #{$example};
}

Which results in:

:root {
  --uxp-icon-chevron-up-lt: url("data:image/svg+xml;utf-8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24'><path fill-rule='evenodd' d='M19.39 14.99l-1.41 1.41L12 10.43 6.02 16.4l-1.41-1.41L12 7.6l7.39 7.39z' clip-rule='evenodd'/></svg>"); }
UnleashSpirit commented 3 years ago

Hi,

No news ? I have the same error on a 600Ko already minify scss file that I have to ingegrate. "property \"url\" must be followed by a ':'" The workaround may have been a solution since I dont have 52 occurences of 'url()' lol

$ node -v
v12.13.1
$ npm -v
6.12.1
$ npx node-sass -v
node-sass       5.0.0   (Wrapper)       [JavaScript]
libsass         3.5.5   (Sass Compiler) [C/C++]
predam commented 2 years ago

Any update?

martirook commented 1 year ago

I got this error when updated bootstrap. Works good on bootstrap 5.1.3

jivansupe commented 1 year ago

I have bootstrap 5.1.3, still facing the same issue. Any leads on this?

Eoic commented 1 year ago

I am experiencing the same issue with Bootstrap 5.2.3. Downgrading to 5.1.3 didn't work.