Search code examples
cssruby-on-railssasshex

SASS invalid syntax hexadecimal color on 8 degit with rails?


I tried to use native the RGBA syntax (#0abf3055) with SASS (in rails 6 app project):

background-image: linear-gradient(to right, #0abf3055, #22242F 30%)

but I got :

Invalid CSS after "": expected expression (e.g. 1px, bold), was "#0abf3055"

if i replace by rgba(#0abf30, 0.33), or just #0abf30 it works, so its 8 degit syntax who have a problem with SASS.

But in documentation it's ok : https://sass-lang.com/playground/#eJwzMNRLzUnNTc0t4VJQSEpMzk4vyi/NS9HNzE1MT7VSyMnMS00s0k0vSkzJTM0r0SjJVyjKTM8o0VFQNkhMSjM2MDUFMo2MjEyM3BSMDVQ1ubgAdAgY1w==

So, how can I use native 8 digits syntax for color with SASS on rails ?


Solution

  • How can I use native 8 digits syntax for color with SASS on rails?

    You use Dart Sass which is the only currently supported SASS implementation.

    Rails historically went from the original Ruby SASS compiler to LibSass. Both of which are long dead and do not support all the modern features/functions of the language. The sass-rails and sassc-rails gems integrate these old deprechiated parsers with Rails.

    If you're using the old sprockets asset pipeline for your stylesheets you may be able to use the dartsass-sprockets gem after installing the dependencies for Dart Sass.

    But you may want to consider ignoring the issue until upgrading to Rails 7 and making a decision about where you want to go in terms of assets handling.