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

How to set sass options for silencing deprecations? #265

Closed
javierjulio opened this issue Nov 15, 2024 · 4 comments
Closed

How to set sass options for silencing deprecations? #265

javierjulio opened this issue Nov 15, 2024 · 4 comments

Comments

@javierjulio
Copy link

javierjulio commented Nov 15, 2024

I'm using sassc-embedded in a Rails app to update foundation-sites and foundation-emails to new versions that require Dart Sass which I'm very close to and will eventually swap to using sass-embedded directly. Thank you.

I don't believe I've ever had to set sass options before even when I used sass-rails v6 so the examples here suggest we should be compiling our sass directly but when using sprockets-rails it would be handled automatically. So it's confusing and unclear how I would change one of the options if I'm not directly calling the compile method.

With this gem, how do we set a sass option, for example quiet_deps to silence deprecation warnings, when using the sassc-embedded gem? And then again when using the sass-embedded gem directly? Both would be alongside sprockets-rails only. We are not using dartsass-sprockets and we have removed sassc-rails.

@javierjulio javierjulio changed the title How to set sass options? How to set sass options for silencing deprecations? Nov 15, 2024
@ntkme
Copy link
Member

ntkme commented Nov 15, 2024

If you're using sass-embedded completely standalone:

require 'sass-embedded'

Sass.compile('application.scss', quiet_deps: true).css

Sass.compile_string(sass, quiet_deps: true).css

If you're using sassc-embedded completely standalone:

require 'sassc-embedded'

SassC::Engine.new(sass, quiet_deps: true).render

If you're using sprockets-rails + sassc-embedded without sassc-rails or dartsass-sprockets:

    config.assets.configure do |env|
      sass_config = {
        quiet_deps: true
      }
      env.register_transformer 'text/sass', 'text/css', Sprockets::SasscProcessor.new({ sass_config: })
      env.register_transformer 'text/scss', 'text/css', Sprockets::ScsscProcessor.new({ sass_config: })
    end

In addition to quiet_deps, you may also want to use silence_deprecations option.

@ntkme ntkme closed this as completed Nov 15, 2024
@javierjulio
Copy link
Author

@ntkme thank you. That worked. I had tried several attempts at a monkey patch but failed. Thank you again. Once we are ready to replace sassc-embedded with sass-embedded, can we still use sprockets-rails with sass-embedded as we did with sassc-embedded? Or it won't work and our we have to migrate to dartsass-rails?

@ntkme
Copy link
Member

ntkme commented Nov 15, 2024

sprockets does not have direct integration for sass-embedded's new API, which is why sassc-embedded was created in the first place - to emulate the old SassC API so that sass-embedded can be used with nearly all existing code.

Current options for rails are:

  • sprockets-rails + sassc-embedded
  • sassc-rails + sassc-embedded
  • dartsass-sprockets + sassc-embedded
  • dartsass-rails + sass-embedded
  • other JS based bundlers...

I previously said in sass/sassc-ruby#220 that sassc-embedded will not be supported after @import gets dropped. However, the situation has changed since sass/sass#3688, which made it possible to support sassc-embedded in long term, and it will have support as long as it is technically feasible.

sassc-embedded won't get all the new features in sass-embedded's new Ruby API, but it should still be enough for majority of the use cases, so there is no need to rush on getting rid of sassc-embedded if you still prefer sprockets.

@javierjulio
Copy link
Author

Thank you, that breakdown is very helpful. Basically, the conclusion I came to on my own. The main concern is still having JS compiled and served through sprockets that cannot be easily migrated so looking for options to stick with sprockets for now. Otherwise, I'd just migrate to dartsass-rails and propshaft. Thank you again for the help and these libraries.

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

2 participants