Thursday, November 26, 2015

Speed up Saleforce Development

Fast Salesforce `staticresrouces` Development Locally

The problem with front end development in the cloud is that it is painfully slow! Unfortunately this is the reality of the cloud nature of SF and it will remain so - at least until there will be ability to spin up local SF development servers.

It takes about 30 seconds or more to save on a busy org. That is mainly because of the typical save cycle, 'change', 'zip', 'save to server', and then 'refresh in browser':

  • doing this many times a day adds up to a substantial time lost
  • loss of focus/concentration - while you wait
  • ‘clobbering of static resources’ when working in a team
  • pure maddening in tight timelines

Current Solutions

Make changes in browser, ex. Chrome
  • Great for CSS
  • Limited for JS (can’t re-run `onload` event)
  • Cumbersome for HTML
  • Can’t use your favorite (Eclipse IDE) editor
Develop files locally
  • Ok for initial design mockups
  • Impractical once code starts living in SF
  • Javascript / CSS injection
  • Browser security issues as file must live on server
  • Ok for CSS, problematic for JS
  • Order issues, `onload` event, etc.
  • Can’t do HTML

  • The Solution: Have Charles or Fiddler serve it!

    The idea is to use an intermediate proxy to highjack our requests and inject files from a local file system. There are two mainstream popular programs to accomplish this. An old and tried Fiddler for Windows machines and Charles Mac

    Once you setup Charles or Fiddler you can map any server response to local files. In the case of CSS/JS this allows you to edit these locally and immediately be able to preview your changes in the browser. Since the common design pattern is to use folder for static resoruces you can just map the entire `resource-bundles` folder instead of individual files:

    • In Charels the 'Path' matching pattern should be of format `/resource//*` mapped to local path to the bundle in `resource-bundles` folder (a Maven's Mate convention that Eclipsers should follow).
    • For Fiddler the 'AutoResponder' rule should be `REGEX:.+?//$` mapped to `\resource-bundles\\$2`.

    If you found this useful please feel free to comment or follow me .

    No comments:

    Post a Comment