Dynamically recompile stale assets
connect middleware for dynamically recompiling derived files at serve-time. This module is designed for speeding up development; best-practices would have you compile all necessary files as part of your production deploy process. But you knew that, of course.
Usage is the same as all other
var connect = require'connect'compiler = require'connect-compiler'server = connectcreateServerconnectloggercompilersrc : 'src'dest : 'var'enabled : 'coffee' 'uglify'connectstatic__dirname + '/public'connectstatic__dirname + '/var';serverlisten6969;
Of note, earlier versions of
connect actually came with a module like this, but they do not any longer.
The compiler middleware takes a settings object, minimally containing a list of compilers to
enabled). Most uses will also specify a source directory (
||Required Enabled compiler id(s). See below for included compilers.|
||cwd||Directories to search for source files to compile.|
||Directory to write compiled result.|
Allows you to specify multiple, ordered
Logging verbosity. Valid values (case-insensitive):
||Creates intermediate directories for destination files.|
||Prefix trimmed off request path before matching/processing.|
||Automatically treat files as stale if this old in secs.|
||Milliseconds after which to kill subprocess commands.|
||Invoke all compilers that match? otherwise, only first.|
||Requests matching this pattern are short-circuit ignored, and no compiler matching occurs.|
HTTP methods compiler should process. This setting is global-only -- per-compiler overrides specified via
Hash of additional per-compiler options, mapped by compiler id. Each compiler is supplied a copy of the
To enable a compiler, you specify its
id, which you can get from the handy list that follows. Some
compilers take options, which you pass using the
options setting using the compiler
id as the
For example, to disable the
bare option for the CoffeeScript compiler, you'd do something like:
server = connectcreateServercompilersrc : 'src'dest : 'var'enabled : 'coffee'options :'coffee' :'bare' : falseconnectstatic__dirname + '/public'connectstatic__dirname + '/var'
sass-- Using sass.js.
sass_ruby-- External compiler using a shell command to the Ruby version of Sass (which you must install that part yourself).
If you're interested in contributing, note that at the moment, a version of
node-seq is checked in under
node_modules while we wait for a pull request to be pulled into