0.0
No commit activity in last 3 years
No release in over 3 years
Fast serving Rails assets in development
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0

Runtime

 Project Readme

Assets::Watchify

Gem Version

Fast serving Rails assets in development.

Useful for Rails applications with hundreds of JavaScript files (eg Backbone Marionette at client side).

This Gem doesn't use Watchify, Browserify or Node.js. Rails Assets Pipeline is smart enough to do all the job. We just set a couple of hooks.

Installation

Add this line to your application's Gemfile:

gem 'assets-watchify', group: :development

And then execute:

$ bundle

Or install it yourself as:

$ gem install assets-watchify

Usage

Create folder public/assets/w6y and start rails server.

Operation

The Gem:

  • Instructs Rails to concatenate CSS files together
  • Installs hook on generating JavaScript tag
  • Combines all JavaScript assets into single file
  • Generates SourceMap for concatenated JavaScript
  • Listens to changes in asset folders and rebuilds JavaScript files

For Rails v3 it's enough.

Rails v4 (if not using puma) is slooow serving large files (and combined JavaScript is large!). Use nginx as reverse proxy:

server {
  listen 80;

  root  /my/Rails/app/public;

  location @Rails {
    proxy_pass http://127.0.0.1:3000;
  }

  location / {
    try_files $uri @Rails;
  }
}

Precompilation

It's useful sometimes to compile large JavaScript on Rails server start. Request this with preload method:

# config/initializers/watchify.rb
Assets::Watchify.preload 'application.js', 'my/other.js' rescue nil

preload without arguments is preload 'application.js'.

See also

Credits