0.02
No commit activity in last 3 years
No release in over 3 years
Guard::Sprockets automatically packages your JavaScript files together.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

~> 2.0
~> 2.0
~> 2.0
 Project Readme

Guard::Sprockets

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).

Install

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'
end

Add guard definition to your Guardfile by running this command:

$ guard init sprockets

Usage

Please read Guard usage doc

Guardfile

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'
end

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

Options

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/turbolinks.js.coffee -> public/js/vendor/rails/turbolinks.js
                                  # and with this option set to false: app/js/vendor/rails/turbolinks.js.coffee -> 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

Development

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 (irc.freenode.net).

Author

Aaron Cruz (@mraaroncruz, aaroncruz.com)

Maintainer

Rémy Coutable

Contributors

https://github.com/guard/guard-sprockets/graphs/contributors