A JavaScript/CoffeeScript concatenation tool for Node.js inspired by Sprockets. Used by connect-assets to create a Rails 3.1-style asset pipeline.
Written in CoffeeScript by the author of CoffeeScript: Accelerated JavaScript Development.
As of May 1st, 2013, @pthrasher became the maintainer of this package. It was taken over from @TrevorBurnham.
Since taking over, the following items have been addressed.
- Source-map support
- Move tests from node-unit over to jasmine.
- Break out pieces into separate files.
- More tests
- More documentation
You can track my progress on these tasks via Pull Request #43
In your CoffeeScript files, write Sprockets-style comments to indicate dependencies, e.g.
#= require dependency
(or //= require dependency
in JavaScript). If you want to bring in a whole folder of scripts, use
#= require_tree dir
First,
npm install snockets
Then in your app:
Snockets = require 'snockets'
snocket = new Snockets()
snocket.scan([filename])
dependentFiles = snocket.getChain()
The Snockets
constructor takes an path_env
key in an optional hash, the value is an array of directory paths. This option provides the search path for required files.