3 ms·
I have been progressively enhancing an older Rails+jQuery app with Vue.js components, and integration has been a breeze. Things I'll note: - Rails effectively
by inopinatus 9y ago
I have been progressively enhancing an older Rails+jQuery app with Vue.js components, and integration has been a breeze.
Things I'll note:
- Rails effectively now has two asset pipelines. Sprockets has been the off-the-shelf inclusion for some years. The Webpacker gem is making Sprockets look out-of-date and under-maintained. Adding Vue to the existing project has been trivial, using Webpacker. At some point, somethings gotta give and we choose one or the other. My money is on Webpacker.
- Vue components are very readable. For a Rails-first developer looking to be productive this has been a huge win over the other "big three" comparable frameworks.
- Building a real-time control panel with ActionCable and Vue was amazingly easy - there was no impedance mismatch between the client and server side - and the result is surprisingly reliable and extremely performant even for mobile clients with patchy connectivity. The hardest part was finding the right nginx+ELB configuration to handle the Websockets upgrade.
- One of the first things I always seem to build is higher-level abstractions for forms, such that (for example) client- and server-side validations render with consistent L&F and without POLA violations in the UX. Vue gives some excellent primitives to assist e.g. v-model, but some kind of next-level abstraction for forms is an obvious next step for the integration.
- I see the peanut gallery is sledging the "template language", not realising that one may switch template formats with ease. I've seen Vue components written in JSX, Haml, Pug et al. Obviously it's better if a team standardises, but complaining about the "template language" means you missed a full understanding of what you're looking at.
- Turbolinks is, as usual, a pain in the ass. By reimplementing basic web browser functions such as navigation and page caching as a frankly premature optimisation, Turbolinks introduces numerous incompatibilities and misbehaviours. There are compatibility shims, but adding and maintaining such for every glitch your users encounter is gonna suck for everybody. Top tip, if you're using Vue with Rails, disable Turbolinks.
- whitefang 9y agoSo true. I've felt all these pains. :) About choosing one asset pipeline, what if the Vue could be the new ERB? Here I have a question on the same. I would love to work on this. https://stackoverflow.com/questions/43084499/replacing-rails-erb-template-with-vue https://stackoverflow.com/questions/43084499/replacing-rails...