ruby-on-railssassruby-on-rails-8

How to use SCSS in a rails 8 project?


I just started a new Rails 8 (Ruby 3.4.1) project with the new propshaft asset pipeline and I can't get SCSS to work. I've tried adding the sassc-rails gem to my gemfile, like in my recent Rails 7 project, but when I run bundle install, I get an error message that looks life this :

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
An error occurred while installing sassc (2.4.0), and Bundler cannot continue.

In Gemfile:
  sassc-rails was resolved to 2.1.2, which depends on
    sassc

I've tried replicating anything related to style and file imports in my new app from my rails 7 app, but nothing worked for me. Any idea how to use SCSS in Rails 8 ?


Solution

  • Add these lines at your Gemfile and Procfile.

    gem 'dartsass-rails' # Gemfile
    
    css: bin/rails dartsass:watch # Procfile.dev