node.jsexpresscoffeescriptnode.js-connect

the connect middleware for coffeescript?


Yes I know connect-assets. But I hope the coffeescript files can be compiled on request. Just like in stylus middleware.

app.use(stylus.middleware(
  src: __dirname + "/assets",
  dest: __dirname + "/public"
))

So, is there anything that works this way?

I know connect.compiler too. But it has been removed in newest version of connect.


Solution

  • I've just published a new module, npm install connect-coffee-script, which does just that. Documentation and a sample are provided as well as an introduction article.

    Here's an exemple from the readme:

        var coffeescript = require('connect-coffee-script');
        var connect = require('connect');
    
        var app = connect();
    
        app.use(coffeescript({
            src: __dirname,
            dest: __dirname + '/public',
            bare: true
        }));
    
        app.use(connect.static(__dirname + '/public'));
    
        app.listen(3000)