Building
Overview
The Fleegix.js build system uses Rake, "a simple Ruby build program with capabilities similar to make." Why Rake? I'm a big fan of Ruby, and Rake is simple, flexible, and powerful.
Here's what you can currently do with the build system:
- Build a compressed fleegix.js from the source files.
- Selectively add plugins to your built fleegix.js file.
- Do a plugins-only build to use Fleegix.js plugins with other JS toolkits.
Here's what you'll need to use the build system as-is, out of the box:
- The Ruby language. (There are people who don't already have it? :))
-
Rake. (If
you have RubyGems,
you can install it with
gem install --remote rake. - The YUI Compressor . (It's a Java app, so you also need Java.)
Basic Use
The default task just builds a compressed fleegix.js file in the project root directory using all the .js files in the src directory.
The build system uses the YUI Compressor by default, so you'll need to download that and set $YUI_COMPRESSOR_PATH in the RakeFile to point to it. I put it in a 'lib' directory in the project root, so mine looks like this:
$YUI_COMPRESSOR_PATH = 'lib/yuicompressor-2.1.2.jar'
You can run the default task simply by typing
rake (with no parameters) in the project base
directory. The output will look something like this:
mde@by-tor fleegix_js $ rake
Getting list of base source files ...
Reading and concatenating source files ...
Built fleegix.js.uncompresed.js
Compressing concatenated file ...
Built fleegix.js
Done.
If you don't have Java or the YUI Compressor, or you
just want to do the compression yourself, you can pass
the compression=false flag to Rake, or set
$COMPRESSION in the RakeFile to false. You'll end
up with a usable, but uncompressed fleegix.js.uncompressed.js
file.
Adding Plugins
To add plugins to your built fleegix.js file, pass
Rake a comma-separated list of plugin files in the
plugins parameter. The 'plugins' directory is
assumed, so all you need to do is pass it the name of the
subdirectory and .js file, like this:
rake plugins="hash/hash.js, popup/popup.js, xml/xml.js"
Plugin-Only Builds
If you want to use some of the Fleegix.js plugins without
the base fleegix.js toolkit (there are few dependencies, so
this works fine in most cases), you can build a compressed
fleegix_plugins.js file of only your selected plugins. Just
pass Rake the plugins_only=true flag, like so:
rake plugins_only=true plugins="xml/xml.js, hash/hash.js"
Plugin-only builds give you a fleegix_plugins.js file.
Profiles
You can save build parameters for reuse in JSON-formatted profile files. Using profiles requires the Ruby JSON library.
Pass the path to this file to Rake in the
profile parameter. I keep my build profiles in
a 'profiles' directory in the project base, so one of mine
might look like this:
rake profile=profiles/epiphanyradio.json
The EpiphanyRadio site uses the XML parser and the Popup library, so its profile file contains this:
{ "plugins": "popup/popup.js, xml/xml.js" }
Some other examples might look like this:
{ "plugins_only": true, "plugins": "popup/popup.js, xml/xml.js" }
{ "compression": false, "plugins": "date/utils.js" }
Cleanup
Use the rake clean command to remove all the
built .js files from the root project directory.