Rails automatically adds the sass-rails gem to our Gemfile, which is used by Sprockets for Sass compilation. But Sass has chosen to focus exclusively on dart-sass, which requires all manner of dependencies that Rails won’t adopt by default. To decrease our reliance on Sass, Rails 7 removed default reliance on Sass and CSS generators and this comes with the idea of using a generator for configuring the CSS processor.
To create a new Rails application, all one has to do is:
This command creates the Rails application and uses Sass as their default CSS processor. If we had to use another CSS processor, we would need to configure it manually after creating the application.
With Rails 7,
we now can create a new Rails application
configure it with the CSS processor options.
Add –css app generator option
PR added the
--css option to the Rails app generator.
Currently, this generator supports the options
When we pass
gem on an importmap/no-JS setup,
After building a Rails 7 application with the above command,
app/views/layout/application.html.erb looks like,
This will automatically link the tailwind styles to the application.