Rails Webpacker or Vue-CLI? Rails Webpacker or Vue-CLI? vue.js vue.js

Rails Webpacker or Vue-CLI?


When i started i went the webpacker way, somewhow because that's what it looked like it was "supposed" to be. As you say, very little guidance.Webpacker (with it's reliance on the latest node) seems a moving target, making deployment and even development more complex. For what benefit i asked and got rid of it.

Now i use vue from the cdn. Benefits:

  • cached close to user
  • almost zero installation
  • easy to have dev/production versions

The i write app code into the rails templates. Using haml, and in fact ruby2js, but you can use javascript just fine. That's how i started, but i like ruby, and the ruby code is almost half the size than the generated js, but i'm getting off track.

So templates are your "vue annoted" rails templates. Small code also goes into the rails template.More code can be defined in the assets and referred to from the app.Even components can be written into template using the x-template syntax.

And last but not least: Data can be transferred by to_json, directly into the templates. And in the same render. Much faster than an additional query. When to_json is not enough one can use rabl to get exactly what is needed.

I hope i made that clear. I am in the process of writing some vue-rails stuff up, as there is so little to be found. Look out here (and i'll comment when the post is ready)