A middleware for connect and union, that compiles and hosts assets (less.js, CoffeeScript, stylus).
This is meant to be a very simple asset compiler that helps speed up development. You add it as middleware in your development environment and it will compile and host all of your assets. This is not recommmended for use during production and it doesn't help you compile your assets for production- not the Rails asset pipeline.
In this example we have a less file
assets/css/style.less on disk that uses bootstrap. When the client requests 'assets/css/style.css' the asset compiler compiles style.less and serves the result.
var flatiron = require'flatiron'union = require'union'assetCompiler = require'asset-compiler'app = flatironapp;appuseflatironpluginshttpbefore:assetCompilermiddleware__dirnamecss: '/assets/css' '/vendor/bootstrap/less';
Defining a compiler is fairly straight forward and the complete list is in an object called
compilerMap because it maps file extensions to compilers. For example, css might map to a less compiler and a stylus compiler.
var less = require'less'_ = require'underscore';varreturncss:var parser =paths: _mapassetscss return root + path;;return parserparsebodyif ecbe;return;cbnull treetoCSS;;;;
I plan to make it easy to override and add new compilers, but the functionality isn't quite there yet. If you add it feel free to submit a pull request.