In Rails 8.1, what does Propshaft do with the files on config.assets.paths, and which Sprockets jobs does it leave to other tools?
answer
- load path, digests, dev server, compilers
- copies every file, not only linked ones
- no transpile, bundle or minify
- public/assets/.manifest.json
- default pipeline since Rails 8.0
basics
~20 sPropshaft gathers every file on config.assets.paths under one logical namespace, serves them in development, and on assets:precompile copies all of them into public/assets with a content digest in each name. It does no transpiling, bundling or minifying.
solid answer
~40 sPropshaft has been the default asset pipeline since Rails 8.0. It gives you four things: a **load path** (every subfolder of `app/assets`, `lib/assets` and `vendor/assets` in the app and its gems, plus anything you append to `config.assets.paths`), **digest stamping** when `bin/rails assets:precompile` copies the files into `public/assets`, a **development server** so nothing needs precompiling locally, and tiny **compilers** that rewrite CSS `url()` references to digested paths. Unlike Sprockets it copies *every* file on the paths, not just what `manifest.js` linked. What it drops on purpose: Sass and CoffeeScript, `//= require` concatenation and minification. Import maps, jsbundling-rails, cssbundling-rails, tailwindcss-rails or dartsass-rails do those jobs now, and Propshaft just digests what they produce.
code
erb · 3 lines<%# app/views/layouts/application.html.erb, as Rails 8.1 generates it %>
<%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>go deeper
Recall the four jobs: load path, digests on precompile, a dev server, url() rewriting. Then name what it skips: Sass, concatenation, minification.
Explain logical paths per load-path root, why every file is copied, and how stylesheet_link_tag :app differs from a single concatenated bundle.
Show you know where each dropped Sprockets job went — import maps, the bundling gems, app/assets/builds — and that old config keys are silent shims.
Frame Propshaft as a deliberate narrowing: build tools own transformation, Propshaft owns digesting and serving, which keeps the pipeline replaceable.
## What Propshaft is **Propshaft** is the asset pipeline a Rails 8.1 `rails new` adds to the Gemfile. It became the default in Rails 8.0, and in 8.1 it is the only pipeline the generator offers (`--skip-asset-pipeline` / `-A` leaves it out; there is no option to pick Sprockets). It was written for a world where HTTP/2 makes bundling less urgent, where JavaScript and CSS are either served as-is through import maps or built by a dedicated tool, and where bandwidth makes minification less pressing. So it does far less than **Sprockets**, the pipeline Rails used by default before 8.0, and it does it faster. ## The four things it does 1. **A configurable load path.** Every subdirectory of `app/assets`, `lib/assets` and `vendor/assets` — in the application and in every engine or gem — becomes a root, along with anything you add to `config.assets.paths`. Files from all of them are addressed by one **logical path** relative to their root, so `app/assets/images/bakery/rye.jpg` is simply `bakery/rye.jpg`. When an app file and a gem file share a logical path, the app wins. 2. **Digest stamping.** `bin/rails assets:precompile` copies every file into `public/assets` under a name such as `application-1a2b3c4d.css` and writes `public/assets/.manifest.json`, the map from logical path to digested path that helpers read in production. 3. **A development server.** In development and test (`config.assets.server`) a Rack middleware serves files straight from the load path, so you never precompile locally. 4. **Basic compilers.** By default only two transformations run: CSS `url(...)` references are rewritten to digested paths, and so are source-mapping comments; in JavaScript only the explicit `RAILS_ASSET_URL("/path")` pseudo-call is rewritten. ## What it deliberately does not do | Job | Sprockets | Propshaft | |---|---|---| | Which files are emitted | only what `app/assets/config/manifest.js` or `config.assets.precompile` linked | every file on the load path | | Sass, CoffeeScript, ERB in assets | built-in or via gems | none — use dartsass-rails, cssbundling-rails, jsbundling-rails | | `//= require` / `*= require_tree` | concatenates files | not processed; the line is just a comment | | Minification | `css_compressor`, `js_compressor` | none | | CSS asset helpers | `image_url()` in Sass | plain `url()`, rewritten automatically | Propshaft still defines `config.assets.precompile`, `compile`, `debug`, `css_compressor` and `js_compressor`, but only as compatibility shims so an old initializer does not crash on boot; setting them changes nothing. ## Referencing assets from views The normal Action View helpers — `asset_path`, `stylesheet_link_tag`, `javascript_include_tag` and the rest — resolve a logical path through Propshaft. Two details matter: - The layout a Rails 8.1 app generates calls `stylesheet_link_tag :app, "data-turbo-track": "reload"`. The `:app` symbol is Propshaft's extension: it emits **one `<link>` per `.css` file** under `app/assets/**`, sorted by logical path. `:all` does the same for every stylesheet on the load path, gems included. Nothing is concatenated, so the sort order is the cascade order. - An asset the load path cannot find raises `Propshaft::MissingAssetError` from `compute_asset_path` instead of quietly emitting an undigested URL. A path you pass with a leading `/` skips the pipeline entirely and comes back unchanged. ## Where the dropped jobs went - **JavaScript without a build step:** importmap-rails pins modules and Propshaft digests the files. - **JavaScript with a bundler:** jsbundling-rails writes its output into `app/assets/builds`, which is on the load path, and Propshaft digests it like any other file. - **CSS with a compiler:** tailwindcss-rails, dartsass-rails or cssbundling-rails do the same into `app/assets/builds`. - **Seeing what is on the path:** `bin/rails assets:reveal` lists logical paths and `assets:reveal:full` the files behind them. The interview point is the split of responsibility: Propshaft owns *finding, digesting and serving* files; anything that changes a file's language or merges files belongs to another tool that runs before it. ## Common misreadings in interviews Candidates who learned Rails on Sprockets tend to carry three assumptions over, and each one produces a confident but wrong answer: - **"Precompile only builds the entry points."** Under Sprockets that was true, and teams spent time adding files to `config.assets.precompile` when a font or image went missing in production. Under Propshaft the opposite problem appears: *everything* on the load path is copied, including source files nobody serves. If a folder holds only inputs for a compiler, it belongs in `config.assets.excluded_paths` (full paths, such as `Rails.root.join("app/assets/stylesheets")`). - **"application.css pulls in the rest."** The comment block at the top of a new app's `application.css` still calls it a manifest file, but nothing is pulled in; the layout's `:app` links each file separately. - **"Production needs a compile step at boot."** It does not. Production reads `public/assets/.manifest.json`, written once by `bin/rails assets:precompile` during the build, and resolves every helper call with a hash lookup. A good short answer names the four jobs, says "every file is copied, nothing is transformed except url() references", and points at the gems that took over the rest.
- What exactly does stylesheet_link_tag :app emit under Propshaft, and why does order matter?It emits one `<link>` tag per `.css` file under `app/assets/**`, sorted by logical path — including built files in `app/assets/builds`. Nothing is merged, so the alphabetical order is the order the browser applies the cascade in. `:all` does the same for every stylesheet on the load path, gem stylesheets included.
- Two gems and your app all ship a file with the logical path reset.css. Which one does Propshaft serve?Your app's. After initialization Propshaft re-sorts `config.assets.paths` so paths under `Rails.root` come before gem and engine paths, and the first file found for a logical path wins. `bin/rails assets:reveal:full` shows which file backs each logical path.
- Propshaft minifies and concatenates CSS and JavaScript the way Sprockets did
- You still list files in app/assets/config/manifest.js so Propshaft precompiles them
- Naming a file application.scss makes Propshaft compile the Sass
- Setting config.assets.precompile limits which files Propshaft copies to public/assets
- A *= require_tree . line still pulls the other stylesheets into application.css
Assumes Rails 8.1 with Propshaft 1.3; Propshaft replaced Sprockets as the default pipeline in Rails 8.0, and rails new no longer offers Sprockets.