Reputation: 3300
Node.js is simply awesome. And it seems as though Express.js is the Sinatra of Ruby for Node.js.
I love how simple Express is. To make things better, I configured it to use CoffeeScript in the backend. I am wondering if there is a way to use auto compile and serve coffeescript files.
Currently I am writing them in a public src
folder, and compiling it to a lib
folder. I would like some thing a little simpler.
Some thing like
[server]/coffee/file.js
-> will provide the compled source of [server]/coffee/file.coffee
?
I found a package, express-coffee
which is as old as Node I guess and not updated in 2 years :(.
Is there any specific way to compile front end coffee script to JS without manual interaction?
Upvotes: 2
Views: 1869
Reputation: 901
I use connect-coffee-script. And this how I use it (in coffeescript) :
app.use require('connect-coffee-script')
src : "#{__dirname}/client/assets/coffee"
dest : "#{__dirname}/client/public/js"
prefix : '/js'
Upvotes: 4
Reputation: 145994
Just use coffee-middleware (or similar) and you can process browser requests for .js
files, locate the corresponding .coffee
files on the server's filesystem, transpile them to javascript, and sent the javascript code down to the browser.
Upvotes: 1