Skip to content

chrisvfritz/rails-javascript-integrations

 
 

Repository files navigation

Sprockets + Browserify + Vue

This version uses the Rails asset pipeline with Browserify. Components are organized into .vue files, JS written in ES6/2015+, with a UMD module system.

Setup

About 30 minutes using vuejs-templates/browserify-simple as a reference.

Usage

Assuming you have foreman installed (gem install foreman), use the development Procfile to launch Rails and Browserify together:

foreman start -f Procfile.dev

Pros

  • A real module system: UMD via Browserify makes organizing JavaScript much easier and works wonders for dead code elimination
  • Babel ES6/2015+: Use the JavaScript of tomorrow, today, extensible via plugins
  • Beautiful components: Write native HTML/JS/CSS with syntax highlighting and other language-specific editor tools
  • Still progressive: You still don't need to have all of your app managed by JavaScript - the parts that need to be really smart can be augmented with custom web components
  • Bye-bye jQuery: This is a good point to ditch jQuery altogether, cutting the build size down by more than half
  • Simple CSRF integration: Only one line of config to get vue-resource's Ajax working with Rails' CSRF security features
  • Hot module reloading: When you change a JavaScript file, updates are instantly applied to the page without state loss
  • Componentized & scoped CSS: Adding scoped CSS to a component is as simple as adding a style tag with the scoped attribute

Cons

  • Slightly more advanced setup: Total setup took about 30 minutes by hand
  • Potentially more complex CSS: Two sources of CSS mean that depending on the team, designers and developers may have to coordinate more on design if they want to take advantage of component CSS

About

Progressive integration strategies for JavaScript-heavy Rails apps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published