Skip to content

Node.js compatible version of Sprokets. Used for resolving Sprokets dependencies.

License

Notifications You must be signed in to change notification settings

Bloc/snockets-bloc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snockets

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.

The state of the package

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

Usage (script-side)

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

Usage (Node-side)

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.