I think a good middle ground here is that HTML web components article that was shared here a few weeks ago: https://gomakethings.com/html-web-components/
I like this because it's still fairly low-code but you get cool stuff out of the box like attributeChangedCallback. You don't have to mess with build tools, which is what I like the most about this strategy. I can just drop these components into my Rails views like any other element, and their custom functionality gets mounted up as soon as they get folded into the DOM. No more document.querySelectorAll(".foo-bar").forEach(foo => bar()). Much cleaner, and the intent is more clear too. With <foo-bar>, it's much more obvious that the element has scripting attached to it than <div class=”foo-bar">.