3

I'm building a set of one-page applications. I want all the resources that app needs to be delivered in one big initial payload.

Each version gets it's own asset package but they are all a part of the same parent app.

What is the best way to set something like this up to deliver sets of resources?

fancy
  • 48,619
  • 62
  • 153
  • 231

1 Answers1

0

connect asset manager (click the link to the docs) will combine separate CSS/JS files into a single file, compress them, convert images to base64 for embedding with data URIs into your CSS files, minify the code, etc

From the README:

What does it allow you to do?

  • Merge and minify CSS/javascript files
  • Auto regenerates the cache on file change so no need for restart of server or manual action.
  • Run pre/post manipulation on the files
  • Use regex to match user agent so you can serve different modified versions of your packed assets based on the requesting browser.
  • Supplies a reference to the modified dates for all groups through assetManager().cacheTimestamps[groupName] as well as md5 hashes assetManager().cacheHashes[groupName] which can be used for cache invalidation in templates. Wildcard add files from dir
Peter Lyons
  • 142,938
  • 30
  • 279
  • 274
  • Will this compile coffee script? – fancy Jan 25 '12 at 09:59
  • Could you add a little more explanation about what connect asset manager does? – mtsr Jan 25 '12 at 12:11
  • @fancy no, this won't compile coffeescript files for you, but see http://stackoverflow.com/questions/8998742/merge-coffeescript-into-your-node-project/8999072#8999072 for how to use express middleware to compile coffescript on the fly. – Peter Lyons Jan 25 '12 at 14:23
  • @PeterLyons Compile and then add into this asset manager? I'm looking to get to one js file and one css file. – fancy Jan 25 '12 at 14:25
  • I think you can use the connect assetmanager hooks to compile coffeescript to javascript as the assets are built. Give it a shot. It's built to address your goal. – Peter Lyons Jan 25 '12 at 18:55
  • It can compile coffeescript for you. You can pass in a compile function that does whatever you want to a file. I write one when I was using it, I'll look for it. – fent Jan 25 '12 at 22:43
  • Here https://gist.github.com/1679405 – fent Jan 25 '12 at 22:50