Dart Sass for Ruby

build gem

Use dart-sass with Ruby and Sprockets.

This gem is a fork of sass/sassc-ruby which maintains API compatibility but delegates to the sass-embedded gem which provides native binaries for 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 migrated in a future major version.

Upgrading to Dart Sass

The interface of sassc-ruby is largely unchanged, however:

  1. Option style: :nested and style: :compact behave as style: :expanded. Use style: :compressed for minification.
  2. Option :precision is ignored.
  3. Option :line_comments is ignored.
  4. Sass2Scss functionality has been removed.

See the dart-sass documentation for other differences.

Installation

Add this line to your application's Gemfile:

gem 'dartsass-ruby'

Rails/Sprockets users should additionally add sassc-rails:

gem 'sassc-rails'

Usage

This library utilizes dart-sass to compile SCSS or SASS syntax to CSS. To compile, use a SassC::Engine, e.g.:

SassC::Engine.new(".klass1, .klass2 { color: :red; }", style: :compressed).render

Alternatives

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

Credits

  • This gem is maintained and used in production by TableCheck. (We'd be very glad if the Sass organization could take over maintainership in the future!)
  • Kudos to @ntkme for dart-sass support.
  • Credit to Ryan Boland and the authors of the original sassc-rails gem.
  • See our awesome contributors.

Changelog

See CHANGELOG.md.

Contributing

Project Setup

  1. Clone repo
  2. Install dependencies - bundle install
  3. Run the tests - bundle exec rake test

Code Changes

  1. Fork it (https://github.com/sass/sassc-ruby/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