Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Guard plugin for Sprockets JavaScript packaging library
Branch: master
Pull request Compare This branch is 36 commits ahead of pferdefleisch:master.

Merge pull request #10 from guard/update_project

update to use Guard::Compat
latest commit f381677a05
@e2 e2 authored


Gem Version Build Status Dependency Status Code Climate Coverage Status

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 1.9.3, 2.0.0, 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.