0

Mojito static assets in production

I'm a bit new to Mojito, so my apologies if this has already been asked and answered.  What's the proper way of managing static assets (CSS, images, video, etc.) for production use in Mojito?

I'm used to the Django-style way of doing things, where I would run 'python manage.py collectstatic', and it would collect all of my static assets from each of my apps (mojit-equivalent) and put it into a single directory.  I would then just serve all of those static assets from a CDN.

For Mojito, the closest thing I could find was 'mojito compile [type]'.  Is it best practice for Mojito to serve all CSS inlined in the HTML rather than from a CDN?  Even if so, is there a way I can quickly grab all of my other static media, and then set a static URL for a CDN to serve them from?

Thanks for the help!

Clarence

by
4 Replies
  • Hi Clarence!

    As you've discovered, "mojito compile all" has some limitations. We recommend Shaker for asset management: it's very complete, and integrates nicely with Mojito.

    https://github.com/yahoo/mojito-shaker
    http://developer.yahoo.com/cocktails/shaker/

    Let us know if it doesn't answer your needs!

    --Ren
    0
  • Hi I'm Diego, the main developer for Shaker.
    Let me give you a quick overview:

    Shaker runs primary on build time: it analyze all your assets in your application, css and js (binders,yui-modules, and it's dependencies) and it will rollup minify and bundle all your files for production. Shaker will optimize the way the rollups are generated and the files being included, which means it will generate a lot of rollups, and in runtime Shaker will pick the more suitable for you regarding the context(device,action...)
    Also shaker allows you to upload the files directly to CDN, for example Amazon S3 transparent for you.

    Shaker is almost transparent from a developer point of view: the idea is that you just set the configuration of your app to use shaker once, and that's it.

    At the end of the day no matter how many mojits, or how many dependencies you have, Shaker will make that your application fetch only one or two requests to serve all the resources you need for a particular request.

    Again, more info is here:

    https://github.com/yahoo/mojito-shaker
    http://developer.yahoo.com/cocktails/shaker/ 

    Within the npm package there is a demo, where you can see the basics of Shaker.

    Play a bit with the tool, and if you have any question let us know! We will be happy to help!




    QUOTE(Ren @ 31 Jul 2012 10:55 AM)
    Hi Clarence!

    As you've discovered, "mojito compile all" has some limitations. We recommend Shaker for asset management: it's very complete, and integrates nicely with Mojito.

    https://github.com/yahoo/mojito-shaker
    http://developer.yahoo.com/cocktails/shaker/

    Let us know if it doesn't answer your needs!

    --Ren
    0
  • Thanks a lot, Ren and Diego, I really appreciate it!  I think Shaker is exactly what I'm looking for, I'll give it a shot and provide some feedback afterwards.

    I'm not particularly familiar with using Buildy for deployment, however, and I'm not sure how to do this:  "
    Simply write your custom task, drop it in the tasks directory, and reference it in the shaker config like any other task."

    I can't seem to find where the tasks directory is.  Would this be a part of Shaker or a part of Buildy?
    0
  • So we are not using Buildy anymore we use GearJS which basically is the same but with another api.
    Take a look to the gear library:
    http://yahoo.github.com/gear/

    The s3 task is an example of how you can create a task.

    QUOTE(Clarence Leung @ 31 Jul 2012 9:49 PM)
    Thanks a lot, Ren and Diego, I really appreciate it!  I think Shaker is exactly what I'm looking for, I'll give it a shot and provide some feedback afterwards.

    I'm not particularly familiar with using Buildy for deployment, however, and I'm not sure how to do this:  "
    Simply write your custom task, drop it in the tasks directory, and reference it in the shaker config like any other task."

    I can't seem to find where the tasks directory is.  Would this be a part of Shaker or a part of Buildy?
    0

Recent Posts

in Yahoo! Mojito