开发者

Preparing client side Coffeescript: compiling, uglifying gzipping

On server side I am using Connect and Socket.IO. I want to serve my client side code (also CofeeScript) to be compiled (to JavaScript), uglyfied and gzipped. I looked for Conenct middleware to do this to me and found uglify-js-middleware and gzippo.

However I am not sure what's a good way to have it converted to JavaScript first (is there no API or something?) and whether I should use temporary directories for every step so I can use the src and dest options of uglify-js-middleware and gzippo or whether there is a better way to pipe it through all these things.

It's okay when this simply gets done when starting my application and so I don't care about checks or anything. I could probably use Cake somehow, but I don't really want to add an extra script for this and it would be cool if I could just pipe it so I don't have the need for temporary directories.

Is there maybe some kind of Middleware that does all of this? I really don't think I am the first one who wants to do this.

Oh and maybe the CofeeScript from a client side directory could be combined into one file, but I guess that's not real开发者_开发问答ly a problem.


Ah, if only someone had written a Connect middleware modeled on the Rails 3.1 asset pipeline... oh wait! I recently did: http://github.com/TrevorBurnham/connect-assets

It's pretty early-stage, but it does exactly what you want: compiles CoffeeScript files to JavaScript, concatenates and minifies them in production mode, and doesn't create new files (so no extra git diffs). Try it out and let me know what you think.


check out the compiler middleware: http://senchalabs.github.com/connect/middleware-compiler.html. It does exactly what you want.

app.use express.compiler
    src: "#{__dirname}/public/scripts"
    enable: ['coffee-script']


http://docpad.org can compile it on the server-side very intuitively


Has anyone seen Mincer? https://github.com/nodeca/mincer

I'm choosing a solution now, so I haven't vetted it yet, but looks like it's strongly based on Sprockets, like connect-assets.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜