Rails Propshaft Guide

With the first beta version of Rails 8, Propshaft has become the default asset pipeline for Rails.

Propshaft works quite differently to Sprockets. Mainly, all compilation, minification und concatenation tasks are outsourced to separate gems. The asset pipeline itself is only responsible for loading the assets and fingerprinting them, so they can be cached indefinitely.

This requires quite a different set up than before. This page tries to explain how Propshaft works, and how common use cases can be covered.

How Propshaft works

By default, Propshaft is configured to serve assets from app/assets, and vendor/assets. This allows developers to include them into their pages with the asset tag helpers like javascript_include_tag and stylesheet_link_tag. The assets are served directly in development mode, and copied to public/assets in production mode.

Placing the files in the correct folder and referencing them correctly can be difficult. The most common use cases are explained under the following links.

Dont't know yet what combination of options is the best?

JavaScript

CSS

Static CSS files you wrote yourself →
for the general styling of your page
Static CSS files from libraries →
such as Bootstrap, Lightbox or a slideshow library
SASS stylesheets →
if you don't want to use NodeJS
Static JavaScript modules from libraries →
such as SplideJS, bootstrap or JQuery