Use Stitch allong with Sprockets
This is currently under revision so the gem's API might change but at this state is very less likely
Just include this gem in your Gemfile
# Gemfile gem 'strockets'
Add the gem to your Gemfile and register Strockets on your sprockets environment:
By default Strockets will Stitch every file excluding application.js, templates and those inside a vendor directory or a gem.
But you can force the stitching of a file by adding a directive to your file's header like
//= stitch true|false
Strockets has the following options:
Strockets.namespace: Which namespace to use
Strockets.defaults_to_stitch: Default Action (to stitch or not to stitch)
Strockets.stitch_exceptions: Which files shouldn't follow the default action