Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removal of sassc dependency #1235

Open
marcrohloff opened this issue Sep 1, 2022 · 6 comments
Open

Removal of sassc dependency #1235

marcrohloff opened this issue Sep 1, 2022 · 6 comments

Comments

@marcrohloff
Copy link

Can the sassc dependency be removed?

We are using dartsass and would rather not have this as an explicit dependency

@Deele
Copy link

Deele commented Sep 30, 2022

AFAIK, this project does not support DartSass and is using sassc/LibSass (C++ one, not Ruby one).

DartSass is very different from LibSass, don't expect this project to work properly with it.

@marcrohloff
Copy link
Author

I realize that. It would be nice to not have the unneeded dependency since sassc is no longer maintained and it seems to be working fine for us. Changing to a newer version of bootstrap but that is a much bigger project

@jgraichen
Copy link

Version 3.4.2 did break support for sassc/libsass by introducing math.div. Everyone will have to upgrade to dartsass/dartsass-sprockets now. Using sassc will not work anymore at all.

@rgaufman
Copy link

rgaufman commented Apr 8, 2024

Any update on this? - is there an alternative gem that doesn't use the deprecated sassc?

@nimmolo
Copy link

nimmolo commented Apr 27, 2024

@rgaufman I can confirm that switching from sassc to dartsass-sprockets works for our Rails 7 app.

But if we try to switch to dartsass-rails, assets:precompile fails.

Reading through the code of this gem, it seems that sprockets-rails is not a dependency. Is there anyone who has gotten this to work with dartsass-rails? (I started a new issue for this in #1247)

@mhenrixon
Copy link

mhenrixon commented Aug 2, 2024

@rgaufman I can confirm that switching from sassc to dartsass-sprockets works for our Rails 7 app.

But if we try to switch to dartsass-rails, assets:precompile fails.

Reading through the code of this gem, it seems that sprockets-rails is not a dependency. Is there anyone who has gotten this to work with dartsass-rails? (I started a new issue for this in #1247)

I have the following setup:

# Gemfile
gem "addressable"
gem "bcrypt"
gem "bootsnap", require: false
gem "coffee-rails"
gem "dartsass-ruby"
gem "dartsass-sprockets"
gem "mini_racer"
gem "rails", "~> 6.1"
gem "responders"
gem "sass"
gem "uglifier"

gem "ace-rails-ap", "~> 4.4"
gem "bootstrap-sass", "~> 3.4"
gem "bourbon"
gem "chosen-rails"
gem "ckeditor_rails"
gem "jquery-rails"
gem "jquery-ui-rails"
gem "select2-rails"

Don't judge; I recently upgraded everything and haven't gotten around to dropping jQuery or upgrading Bootstrap.

# config/assets.rb
Rails.application.config.assets.digest = true
Rails.application.config.assets.css_compressor = :sassc

Using liquid and such, I had to update my importer:

# app/utils/sass_importer.rb
 
class SassImporter < SassC::Importer
  def initialize(options)
    @options   = options
    @site_id   = options[:site_id]
    @syntax    = options[:syntax]
    @css_files = options[:css_files].to_a
  end

  def imports(path, parent_path)
    parent_name = parent_path.split("/").last
    return unless (template = find_template(path))

    content = if template.tpl_ext == "sass"
      SassC::Sass2Scss.convert(template.raw_content)
    else
      template.raw_content
    end

    SassC::Importer::Import.new(
      path,
      source: content,
    )
  end

  private

  attr_reader :site_id, :syntax, :css_files

  def find_template(path)
    css_files.find { |t| t.name == path }
  end
end

Now I had to change some imports etc during the upgrade but dartsass-ruby is working great for us with dartsass-sprockets.

It isn't ideal and eventually, I'd love to kill all traces of sprockets.

Unfortunately, dartsass-rails aren't very good yet. I tried it, and it fails to build, and it produced cryptic error messages. You would likely be better off using dartsass on the JS side then (yarn, bun, etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants