Rails 7 default usage


Im learning ror, started with version 6 when webpack was introduced. Now i trying to learn new features of version 7 and im little bit confused.

There is different JS/CSS plugins. I really dont understand some of it. I like the idea using basic tools that are in-box.

After install i have some notifications in console about esbuild or something other. Nvm.

What is default or recommended to use? Question is about js builders and css libs. My eyes are running up.

The default for Rails 7 is import maps for Javascript and Tailwind for CSS. With these choices you won’t need to worry node, yarn or bundlers like esbuild or webpack.

If you have specific needs for JS, like transpiling to ES5, or you want to use many NPM packages, you will replace import maps with jsbundling-rails. This gem provides integration between Rails and a js bundler of your choice: webpack, esbuild or rollbar.

If you want to create your own CSS lib from scratch (maybe your UX team has defined a design system for your app), you will replace tailwind with cssbundling-rails. This gem provides integration between Rails and a css bundler of your choice: postscss, sass, etc.

Finally, if you do switch to jsbundling-rails or cssbundling-rails you will need either Sprockets or Propshaft. Sprockets will still be supported, but Propshaft is the way forward.


Just a caveat, it seems propshaft isn’t yet a Rails default (it is used by rails new when passing -a propshaft). It is still version 0.x and its README states:

This is very much alpha software at the moment.

Ah, yes that’s true. It’s alpha and, as far as I know, only deployed in two production apps: Basecamp’s and mine. So it’s feature set is currently limited to what these two apps required.

That side, inside that feature set, it works well. My app has 11 CSS entrypoints, 6 JS entrypoints and over 3000 image assets. It uses jsbundlinh and cssbundling. Migration took 2 hours and we had no problems so far.

I’m still using Sprockets and Propshaft rather than CSS bundling and JS bundling, not necessarily, and importMap is only used sparingly

I’m using JSBundling and ESbuild for my Rails 7 projects. It offers me more controls over importmap, which I like the idea but I think need to be more mature before I decide to jump into it.