Skip to content
Guard plugin for Sprockets JavaScript packaging library
Find file
New pull request
Pull request Compare This branch is 38 commits ahead of pferdefleisch:master.
Latest commit cad28ac @e2 e2 Merge pull request #11 from guard/travis-container-arch
Switch to Travis container arch and test MRI 2.2.3


Gem Version Build Status Dependency Status Code Climate Test Coverage

Sprockets guard automatically packages your JavaScript files together when your source files are saved.

  • Compatible with Sprockets 2.x (for Sprockets 1.x compatibility, please use Guard::Sprockets 0.1.4 or the sprockets_1 branch).
  • Tested against Ruby 2.0, 2.1, 2.2, Rubinius & JRuby (1.9 mode only).


Please be sure to have Guard installed before continue.

Install the gem:

$ gem install guard-sprockets

Add it to your Gemfile (inside the :tools group for instance):

group :development do
  gem 'guard-sprockets'

Add guard definition to your Guardfile by running this command:

$ guard init sprockets


Please read Guard usage doc


Guard::Sprockets can be adapted to all kind of projects.

Typical Rails 3 app (default generated Guardfile)

guard :sprockets, destination: 'public/javascripts', asset_paths: ['/app/assets/javascripts'] do
  watch 'app/assets/javascripts/application.js'

Please read Guard doc for more information about the Guardfile DSL.


destination: 'public/js'          # change the destination folder in which the compiled assets are saved, default: 'public/javascripts'
asset_paths: 'app/js'             # add a directory (or on array of directories) to Sprockets' environment's load path, default: ['app/assets/javascripts']
asset_paths: ['app/js', 'lib/js'] # asset_paths can be a String or an Array
js_minify: true                   # minify the JavaScript files content using Uglifier. You can pass true, false, or an Uglifier options hash. default: false
                                  # be sure to add: "gem 'uglifier'" in your Gemfile
css_minify: true                  # minify the CSS files content using YUI Compressor, default: false
                                  # be sure to add: "gem 'yui-compressor'" in your Gemfile
keep_paths: true                  # retain the directory structure of an asset's path relative to the asset_path, default: false
                                  # this prevents assets with the same basename, but placed different folders, from overwriting each other in the destination folder
                                  # e.x. with this option set to true: app/js/vendor/rails/ -> public/js/vendor/rails/turbolinks.js
                                  # and with this option set to false: app/js/vendor/rails/ -> public/js/turbolinks.js
root_file: 'app/js/app.js'        # if set, only this file will be compiled, default: nil
root_file: ['one.js', 'two.js']   # root_file can be a String or an Array


Pull requests are very welcome! Please try to follow these simple rules if applicable:

  • Please create a topic branch for every separate change you make.
  • Make sure your patches are well tested. All specs must pass on Travis CI.
  • Update the Yard documentation.
  • Update the README.
  • Please do not change the version number.

For questions please join us in our Google group or on #guard (


Aaron Cruz (@mraaroncruz,


Rémy Coutable


Something went wrong with that request. Please try again.