I've got a simple web app running using Node and Express. I started writing the app in js but would like to transition over to coffee. I'd like to have file1.js and file2.coffee sitting side by side in my app (both served as js), so that I can drop in third party client-side scripts with no friction.
I found connect-assets, but it seems to have a collision of some sort with Express, which is my framework. Express doesn't want to serve files in the ./assets directory. I can ditch Express but I'd need to have a solid reason for it.
What asset pipeline can I drop into Express (or another framework if needed) that will let me keep .js and .coffee files side by side?
Connect-assets should be able to do this.
Add this to the top of your app.js or server.js or whatever you call your main .js file:
require('coffee-script');
This will cause node to compile your coffeescript for you. It also allows so that you can mixin coffeescript and javascript files anywhere in your app and never have to worry about compiling again.
Make sure to do the following:
npm install coffee-script at the command line
Use != js('script1') in your layout.jade.
app.use(require('connect-assets')()); in app.js after app.configure call.
Connect-assets defaults to looking for script files in /assets/js. Also, assets are not available until they are called by a view, so doing a curl on a compiled asset will get a 404 unless it is called as part of a view.