Modern web applications are more likely than not to use a CSS framework like Tailwind,
pre-processors such as CoffeeScript, Sass, and ERB.
It allows assets in the Rails application to be automatically combined with assets from other gems.
Rails automatically adds the
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
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
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
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.