If I have != js('engagement') in my .jade file, and that CoffeeScript file will compile into a .js file on page load and I can then access to the .js file directly.
But I cannot start my Node.js server and go directly to the .js file with /js/engagement.js in the url.
Is there some simple code that I suppose to put in my app.js to get the package “connect-assets” working different for compiling this?
I call this specific problem “priming”; you want to use these files without referencing them in any views. It’s especially problematic with architectures involving requireJS on the front end.
I’ve created a module called
connect-assets-jsprimerthat will prime all your coffeescript files on app startup so that they are available. In essence, it just calls the connect-assetsjs("")function on all the files in you assets/js folder (recursively).Install with:
Usage (in your server.js or whatever)
After this, you should be able to request your javascript files straight away without rendering any views.
Source is up on github at connect-assets-jsprimer