There are a lot of tools that accomplish very similar things in this space. Pinion is meant to be a very simple and lightweight solution. It is driven by these core goals (bold goals are implemented):
- Simple configuration and usage.
- No added syntax to your assets (e.g. no
//= require my_other_asset)
- Recompile all compiled assets when they change (or dependencies change) in development and set mtimes
- Recompile asynchronously from requests (no polling allowed)
- Compile assets one time in production
$ gem install pinion
You should add pinion to your project's Gemfile.
The easiest way to use Pinion is to map your desired asset mount point to a
Pinion::Server instance in your
In your app, you will use pinion's helper methods to construct urls:
<head> <title>My App</title> <link type="text/css" rel="stylesheet" href="<%= pinion.asset_url("/assets/style.css") %>" /> <!-- Shorthand equivalent --> <%= pinion.css_url("style.css") %> </head>
- Currently, Pinion sidesteps the dependency question by invalidating its cache of each file of a particular
type (say, all
.scssfiles) when any such source file is changed.
- The order that paths are added to the watch list is a priority order in case of conflicting assets. (For
foo/bazare both on the watch list, and both of the files
foo/bar/style.scsswill be used if a request occurs for
You can see an example app using Pinion and Sinatra in the
Pinion is released under the MIT License.