connect-compiler
v0.1.3
Published
Dynamically recompile stale assets
Downloads
20
Readme
connect-compiler
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 connect
middleware:
var connect = require('connect')
, compiler = require('connect-compiler')
, server = connect.createServer(
connect.logger(),
compiler({
src : 'src'
dest : 'var'
enabled : [ 'coffee', 'uglify' ]
}),
connect.static(__dirname + '/public'),
connect.static(__dirname + '/var')
)
;
server.listen(6969);
Of note, earlier versions of connect
actually came with a module like this, but they do not any longer.
Settings
The compiler middleware takes a settings object, minimally containing a list of compilers to
enable (enabled
). Most uses will also specify a source directory (src
).
Compilers
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
key.
For example, to disable the bare
option for the CoffeeScript compiler, you'd do something like:
server = connect.createServer(
compiler({
src : 'src'
dest : 'var'
enabled : [ 'coffee' ],
options : {
'coffee' : {
'bare' : false
}
}
}),
connect.static(__dirname + '/public'),
connect.static(__dirname + '/var')
)
Compiler IDs
- CoffeeScript Compiler:
coffee
- Coco Compiler:
coco
- Uglify Compiler:
uglify
- Jade Compiler:
jade
- Stylus Compiler:
stylus
- Less Compiler:
less
- Sass Compiler:
sass
-- Using sass.js. - SassRuby Compiler:
sass_ruby
-- External compiler using a shell command to the Ruby version of Sass (which you must install that part yourself). - Jison Compiler:
jison
Feedback
Find a bug or want to contribute? Open a ticket on github. You're also welcome to send me email at [email protected].
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 master
.