Asset pipeline: Propshaft
Propshaft is the default asset pipeline in Rails 8, and this course reads its installed source alongside one Rails app. It shows how a content hash in the filename makes a URL safe to cache for a year. The lessons cover the load path, assets served on request in development, url() rewriting in CSS, and the split with importmap-rails. They also cover the dynamic and static resolvers and assets:precompile in a Dockerfile. The last lesson traces tailwind.css from source to URL and ends with a Ruby challenge.
What you'll learn
- ✓How fingerprinted filenames let browsers cache assets safely
- ✓How Propshaft builds its load path from app/assets and gem directories
- ✓How Propshaft::Server serves and digests assets on request in development
- ✓How CSS url() references are rewritten and how importmap-rails maps JavaScript modules
- ✓How Propshaft picks between the dynamic and static resolvers
- ✓How assets:precompile writes the manifest used in production
One job: turn a source file into a cacheable URL
Every stylesheet and script a browser loads needs a URL, and that URL has one hard job: telling the browser how long it can keep the file without asking the server again. Get it wrong one way, and every visitor downloads the same unchanged CSS on every request, wasting bandwidth and time. Get it…
Read the full lesson free →Curriculum
7 lessonsOne job: turn a source file into a cacheable URL
Why asset URLs need fingerprints, and how a content hash in the filename keeps cached files from going stale.
The load path: where Propshaft looks for assets
How Propshaft builds its load path from app/assets and gem directories, and where the generated tailwind.css fits.
No compile step: assets are fingerprinted on request
How Propshaft::Server fingerprints and serves assets on each request in development, and how the SHA1 digest is computed.
Referencing assets: url() rewriting and the import map
How Propshaft rewrites url() references inside CSS, and how it shares JavaScript serving with importmap-rails.
Two stylesheet tags, and the resolver behind them
How stylesheet_link_tag resolves logical names, and how Propshaft chooses between its dynamic and static resolvers.
Going to production: assets:precompile and the Dockerfile
How assets:precompile in the Dockerfile writes digested files and a manifest, and how production serves them from disk.
Putting it together: one file, traced end to end
Traces tailwind.css from Tailwind source to cached URL in development and production, then poses a Ruby fingerprinting challenge.