• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Work with all your cloud files (Drive, Dropbox, and Slack and Gmail attachments) and documents (Google Docs, Sheets, and Notion) in one place. Try Dokkio (from the makers of PBworks) for free. Now available on the web, Mac, Windows, and as a Chrome extension!


BuildTools-About Build Tools

Page history last edited by tymofi 11 years, 5 months ago



  • Why build tools?
    • Most people start writing Javascript by adding it  to their web page
    • Too hard to manage your source files once your app gets large
    • Too hard to write optimized code when your computer could help
    • Too hard to manage assets
    • To make an app download and run as fast as possible on the web, you need to use caching.  Making sure your app works properly with caching can be tricky, but the build tools can do it for you.
  • What do SproutCore build tools do?
    • Automatically scans your source code project and builds a manifest of how your source code should be built into a final project
    • Applies localization rules to automatically build different language variations of your project
    • Inserts cache-friendly URLs for any assets (such as images) you might want to load
    • Builds your javascript and stylesheets by combining files, removing comments, and minifying the contents
    • Builds any HTML output by combining template files.  Automatically generates your index.html to load the rest of your javascript in the proper order
    • Reduces the size of images using pngcrush -- someday maybe auto-spriting too..
  • How do they work?
    • Build tools are implemented as a series of command line tools, tied together using a make system based on Rake.  
    • sc-init: when you first create a sproutcore project, use this tool to setup your project
    • sc-server: use this tool while you are developing your code.  
      • This is a simple HTTP server that can dynamically build resources as you request them.  
      • To use this server, you start the server then in  your web browser visit http://localhost:4020/path/to/your/app
      • This will dynamically build your code - and rebuild your code when ever you make changes
    • sc-build: when you are ready to deploy, use this tool to build your final project
      • This builds your your project using the same code as sc-server, but then performs additional optimization steps such as minifying your javascript. 
    • sc-gen: while you are developing your code, you can use this tool to generate new templates for models, views, controller, frameworks, applications and other components.  This can save you lots of time typing.
    • sc-manifest: this tool scans your source directory and builds a manifest file, which describes how your project will be built.  This tool is mostly used internally by sc-server and sc-build, but you can use this sometimes for diagnostic purposes or to make changes to your manifest before an actual build is performed, if you want.
  • Customizing the build tools
    • The build process is controlled by rules defined in a special file in your project called a "Buildfile".  A buildfile may be named "Buildfile", "sc-config" or "sc-config.rb" for backwards compatibility. 
    • The Buildfile is an enhanced version of Rake.  Anything you can do in rake, you can also do in a Buildfile.
    • To customize the way your build system works, you edit this file to either change your configuration settings or to edit the tasks themselves, giving you a chance to call an external tool, etc.
    • Although Buildfiles and Rake are written in Ruby, you don't need to know much Ruby to get along.  Just peek at the default Buildfile that is provided for you and uncomment the section you are interested in.  It contains instructions on how to call out to your own external tools (written in whatever language you prefer), or how to set the configs internally.


Comments (0)

You don't have permission to comment on this page.