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?
EDIT: I know connect.compiler
too. But it has been removed in newest version of connect
.
Connect is an extensible HTTP server framework for node, providing high performance "plugins" known as middleware. More specifically, connect wraps the Server, ServerRequest, and ServerResponse objects of node.
CoffeeScript is a programming language that compiles to JavaScript. It adds syntactic sugar inspired by Ruby, Python, and Haskell in an effort to enhance JavaScript's brevity and readability. Specific additional features include list comprehension and destructuring assignment.
You simple need to add a <script type="text/coffeescript" src="app. coffee"></script> to execute coffee script code in an HTML file. In other cases, I've seen people use the attributes of type="coffeescript" and type="coffee" , so they might work for you as well. Save this answer.
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)
app.use(express.compiler({
src: __dirname + "/assets",
dest: __dirname + "/public",
enable: ['coffeescript']
}));
could also add stylus to the enable array if you are using both!
im using express 2.5.9
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With