📦 Sprockets vs 🧵 Propshaft in Ruby on Rails 7/8 – What’s the Difference?

When working with asset pipelines in Ruby on Rails 7 and 8, you might encounter Sprockets and Propshaft—two asset handling libraries. While both aim to serve static assets like JavaScript, CSS, images, and fonts, they do so in different ways.

This post will walk you through what each does, how they differ, and when you might want to use one over the other.


📦 What is Sprockets?

Sprockets is the original Rails asset pipeline system, introduced way back in Rails 3.1. It allows developers to:

  • Concatenate and minify JavaScript and CSS
  • Preprocess assets using things like SCSS, CoffeeScript, ERB, etc.
  • Fingerprint assets for cache busting
  • Compile assets at deploy time

It works well for traditional Rails applications where the frontend and backend are tightly coupled.

Pros:

  • Mature and stable
  • Rich preprocessing pipeline (SCSS, CoffeeScript, ERB, etc.)
  • Supports advanced directives like //= require_tree .

Cons:

  • Complex internal logic
  • Slower compilation times
  • Relies on a manifest file that can get messy
  • Tightly coupled with older Rails asset practices

🧵 What is Propshaft?

Propshaft is the newer asset pipeline introduced by the Rails team as an alternative to Sprockets. It focuses on simplicity and modern best practices. Propshaft was added as an optional asset pipeline starting in Rails 7 and is included by default in some new apps.

Design Philosophy:
Propshaft aims to work like a static file server with fingerprinting and logical path mapping, rather than a full asset compiler.

Key Features:

  • Uses logical paths (e.g., /assets/application.css)
  • No preprocessing pipeline by default (but supports it via extensions like Tailwind or Sass)
  • Supports digesting (fingerprinting) of assets
  • Leaner and faster than Sprockets
  • Easier to integrate with modern JavaScript bundlers (like importmaps, esbuild, or webpack)

Pros:

  • Lightweight and fast
  • Easier to debug
  • Works great with importmaps and Hotwire
  • Modern, forward-looking approach

Cons:

  • No advanced preprocessing by default
  • Limited plugin ecosystem (still maturing)
  • Doesn’t support old Sprockets directives

🔍 Key Differences at a Glance

FeatureSprocketsPropshaft
Introduced InRails 3.1Rails 7
Default in RailsRails 6 and earlierOptional from Rails 7+
Preprocessing SupportYes (SCSS, ERB, CoffeeScript, etc.)No (only raw assets by default)
SpeedSlowerFaster
Configuration ComplexityHigherMinimal
Plugin EcosystemLarge and matureNew and growing
Use With Importmaps/HotwireCan work, but heavierIdeal
DebuggingHarder due to complexityEasier

🧰 When Should You Use Sprockets?

Choose Sprockets if:

  • You are upgrading a legacy Rails app
  • Your project already relies on Sprockets
  • You use heavy asset preprocessing
  • You need compatibility with gems that depend on Sprockets

⚡ When Should You Use Propshaft?

Choose Propshaft if:

  • You are starting a new Rails 7/8 project
  • You use Importmaps or Hotwire/Turbo
  • You prefer faster and simpler asset handling
  • You don’t need complex preprocessing

Propshaft pairs particularly well with modern frontend workflows like Tailwind CSS (via build tools) or StimulusJS (with importmaps).

🛠️ Switching from Sprockets to Propshaft

If you’re migrating, here are basic steps:

  1. Remove sprockets-rails gem from your Gemfile: # Gemfile # gem "sprockets-rails"
  2. Add propshaft: gem "propshaft"
  3. Update config/application.rb: config.assets.resolver = Propshaft::Resolver.new( paths: [Rails.root.join("app/assets")] )
  4. Remove app/assets/config/manifest.js (used by Sprockets)
  5. Move all assets to the correct logical paths under app/assets
  6. Use digested URLs as needed (asset_path("application.css") etc.)

🧪 Real Example in Rails 8

Here’s how your application.html.erb might look using Propshaft:

<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>

And your app/assets/builds/application.css could be compiled via Tailwind or SCSS using a toolchain.


🧠 Final Thoughts

Sprockets has served Rails well for over a decade, but Propshaft is the new lightweight future. If you’re starting fresh, Propshaft is a strong choice, especially when used alongside Hotwire, Importmaps, or modern JS bundlers.

However, don’t feel pressured to switch if your current Sprockets setup works fine—Rails continues to support both.


✨ TL;DR

  • Sprockets = older, feature-rich, best for legacy apps
  • Propshaft = newer, minimal, better for modern workflows

Choose based on your app’s needs and complexity. Cheers! 🚀

Unknown's avatar

Author: Abhilash

Hi, I’m Abhilash! A seasoned web developer with 15 years of experience specializing in Ruby and Ruby on Rails. Since 2010, I’ve built scalable, robust web applications and worked with frameworks like Angular, Sinatra, Laravel, Node.js, Vue and React. Passionate about clean, maintainable code and continuous learning, I share insights, tutorials, and experiences here. Let’s explore the ever-evolving world of web development together!

Leave a comment