Skip to content
conoremclaughlin edited this page Jan 22, 2013 · 2 revisions

servers/Route#assets stores all arrays of mirrors and/or filepaths to assets to be sent to the client. servers/Route#initializeAssets converts these into mirrors and exposes their content at assets/<mirror>.<type>

The defaults mirrors are:

  • all.js all assets in a single file - compiled from [vendor, core, main, plugins]
  • main.js application code - compiled from [models, templates, views, routers]
  • plugins.js plugins interacting directly with Bones and/or application code (ie. most files in a client or shared folder).
  • core.js core functionality on client for Bones, receives no wrapping beyond closure
  • vendor.js files that do not know of bones at all. plugins like backbone-forms could be added to plugin.js as well.
  • templates.js all templates.
  • models.js all models.
  • views.js all views.
  • routers.js all routers.

Methods

  • Route#exposeClientCore(filename) adds resolved filepath to core.
  • Route#exposeClientVendor(filename) adds resolved filepath to vendor.
  • Route#exposeClientPlugin(filename)adds resolved filepath to plugin.
  • Route#loadClientPlugin(pluginDir) loads all files in pluginDir/client and pluginDir/shared.
  • Route#loadClientPlugins(Bones.plugin) loads /client and /shared for all Bones plugins. Only use if require order irrelevant.

Notes

  • Files in plugins.js are wrapped so they have access to templates, routers, models, views, and Bones itself.
  • Mirrors read from the disk every time their url end point is requested. You either need to put a reverse-proxy in front of it, or publish static files as part of your build process. See publishing.

How To

How do I add a file to a mirror?

Augment the initialize method of Route and add to this.assets.<mirror> a resolved filepath or use a convenience method below.

Clone this wiki locally