0

I am trying to completely remove Sprockets from a Rails 6.1.3.2 with Ruby 3.0 project

One of the Stackoverflow question/answers said that I need to remove the sass-rails gem from the Gemfile.

Per the sass-rails gem Github repo:

This gem provides official integration for Ruby on Rails projects with the Sass stylesheet language.

So, why would it have to be removed if I wanted to write .scss stylesheets instead of .css stylesheets?

EastsideDev
  • 6,257
  • 9
  • 59
  • 116
  • 1
    The `sass-rails` gem supports Sass within the Sprockets asset pipeline. So, it's unnecessary if you remove Sprockets. Assuming you are moving solely to webpack, you'd want to include `node-sass` in your packages and configure the `sass-loader` to process `.scss` files. – rmlockerd May 30 '21 at 19:56
  • Thank you, I will look into this. I want to use webpack only. – EastsideDev May 30 '21 at 19:59
  • 1
    @rmlockerd node-sass is deprechiated. https://sass-lang.com/blog/libsass-is-deprecated – max May 30 '21 at 22:48
  • Got that, thanks. I only needed to remove the sass-rails gem and do yarn add sass-loader – EastsideDev May 31 '21 at 01:08

1 Answers1

2

The sass-rails gem was actually deprecated.

It's a rails (sprockets) wrapper for the venerable Ruby SASS compiler which is extremely slow. It was replaced in 2019 by sassc-rails which used libsass (which is written in C) until that was also axed. In Rails 7, sassc-rails became the default. It is recommended to move away from sass-rails

The primary implementation of SASS is now Dart Sass. You can install it through Node.js, Homebrew, Chocolate, Scout-App etc. You integrate it with webpack through the Sass-loader package.

It supports features like the new module system @use that replaces the problematic @include that are starting to show up in cutting edge frameworks and will be blazingly fast compared to the old Ruby compiler.

Jason FB
  • 4,752
  • 3
  • 38
  • 69
max
  • 96,212
  • 14
  • 104
  • 165
  • 1
    Integrating it via the SASS-loader worked, following @rmlockerd advice. yarn add sass-loader, and I removed the sass-rails gem. – EastsideDev May 31 '21 at 01:06