Low commit activity in last 3 years
There's a lot of open issues
Use Dart Sass with Sprockets and the Ruby on Rails asset pipeline.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Dart Sass for Spockets

build gem

Use Dart Sass with Sprockets and the Ruby on Rails asset pipeline.

This gem is a fork of sass/sassc-rails which maintains API compatibility but delegates to the sass-embedded gem which uses Dart Sass instead of the libsass C implmentation.

For ease of upgrading, the root namespace ::SassC is still used by this gem, although it is now a misnomer. This is planned to be renamed in a future major version release.

Installation

Add this line to your application's Gemfile:

gem 'dartsass-sprockets'

This will automatically configure your default Rails config.assets.css_compressor to use :sass.

Version Support

The current version of dartsass-sprockets supports:

  • Ruby 3.1+
  • Rails 6.1+

For older versions of Ruby and Rails may be supported with earlier versions of this gem.

Upgrading to Dart Sass

This gem is a drop-in replacement to sass-rails. Note the following differences:

  • This library does not apply SASS processing to .css files. Please ensure all your SASS files have file extension .scss.
  • config.sass.style values :nested and :compact will behave as :expanded. Use :compressed for minification.
  • config.sass.line_comments option is ignored and will always be disabled.

Inline Source Maps

To turn on inline source maps, add the following configuration to your development.rb file:

# config/environments/development.rb
config.sass.inline_source_maps = true

After adding this config line, you may need to clear your assets cache (rm -r tmp/cache/assets), stop Spring, and restart your Rails server.

Note these source maps are inline and will be appended to the compiled application.css file. (They will not generate additional files.)

Alternatives

  • dartsass-rails: The Rails organization maintains its own wrapper for Dart Sass. Unlike this gem, dartsass-rails does not support Sprockets.

Credits

Contributing

  1. Fork it (https://github.com/tablecheck/dartsass-sprockets/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature') - try to include tests
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request