Package assets into gems for non-Rails Sprockets 2.x applications.
$ gem install sprockets-plugin
To use Sprockets plugins, you only need to do 3 things:
- Require "sprockets-plugin" to hook everything up. This may be required by the plugins themselves, but it's best practice to also require this in your application.
- Require any plugins you want to use.
- Call Sprockets::Environment#append_plugin_paths after setting up your application paths. Sprockets::Plugin does not automatically append paths to the environment. This is because the plugin paths would take precedence over your application's paths.
Here's an example:
Sprockets::Plugin is meant to be used within gems, to package assets for reuse. Again, there's only 3 things to do to set this up.
- Add it as a dependency in your gemspec.
- Extend Sprockets::Plugin.
- Add the necessary paths.
Gem::Specification.new do |s| # ... s.add_runtime_dependency "sprockets-plugin" # 1. end
Copyright (c) 2011 Peter Browne. See LICENSE for details.