Dart Sass for Ruby
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:
- Option
style: :nestedandstyle: :compactbehave asstyle: :expanded. Usestyle: :compressedfor minification. - Option
:precisionis ignored. - Option
:line_commentsis ignored. Sass2Scssfunctionality 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
- Clone repo
- Install dependencies -
bundle install - Run the tests -
bundle exec rake test
Code Changes
- Fork it (https://github.com/sass/sassc-ruby/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - try to include tests - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request