Rails 7.0 makes Sprockets an optional dependency

Sprockets is a crucial Ruby library that is used to serve and compile web assets. However, in Rails 7.0 the library becomes an optional dependency unless the application needs to use Sprockets. In such situations, the sprockets-rails gem will have to be added to the Gemfile.

1
gem "sprockets-rails"

Before Rails 7.0

Rails would create app/assets/stylesheets/application.css whether the app was generated using the --skip-sprockets command. This was so developers could have the option of easily adding the asset pipelining at a later stage should they want. The generated file had the following lines added:

1
2
3
4
/* ...
 *= require_self
 *= require_tree .
 */

After Rails 7.0

For applications that will be generated with --skip-sprockets, app/assets/config/manifest.js and app/assets/stylesheets/application.css will no longer be generated.