Guide to Rails 7 and the Asset Pipeline

The Rails pipeline executes multiple tasks:

  1. Transpilling files (coffescript to javascript, sass to css)
  2. Bundling files (combining all js files into a single application.js, same for css)
  3. Digesting files so they can be properly cached.

Sprockets was built to handle all 3 tasks. However with advances in bundlers like webpack, esbuild, dart, etc., Sprockets was left behind in terms of features and performance.

Because of that Rails 7 decided that tasks 1 and 2 should be replaced by importmaps (with importmaps-rails) or bundlers (with jsbundling-rails and cssbundling-rails).

So when I say “don’t use sprockets” I mean “don’t bother to use sprockets for tasks 1 and 2”. However, whatever approach you take, you will still need something to handle task 3. And those something are Sprockets and Propshaft.

PS: Sorry, can’t help you with that one. I don’t use importmaps, but the bundler gems, so I’m not certain how this should be done. I remember seeing guides for this though, so probably a google search for “rails importmaps bootstrap” will return a guide for this.

PPS: Beleza Pietro? Ta em qual cidade?

4 Likes