This section provides a brief overview of how the Alloy command-line interface converts the files in the app folder to a Titanium project in the Resources/<platform> folder for each platform you build your project for. Before Alloy 1.3.0, Alloy creates only one Titanium project in the Resources folder.
The Resources folder is cleaned of any previous built files.
If the build configuration file, alloy.jmk, exists, it is loaded. The 'pre:load' task executes at this point if it is defined.
Alloy Framework, Assets and Lib
Alloy framework files, which include the Backbone.js and Underscore.js libraries, sync adapters and base controller class, are copied to the Resources/<platform>/alloy folder. The Alloy base library, alloy.js, is copied to the Resources folder. These files are necessary to run any Alloy project.
The project configuration file, config.json, is processed and copied to Resources/<platform>/alloy/CFG.js.
The files in the assets and lib folders, as well as the files in the theme's assets folder, are copied to the Resources folder.
The 'pre:compile' task executes at this point if it is defined.
Model-View-Controller and Widget Generation
Alloy creates a skeleton app.js file from a template. The contents of this file require some Alloy modules and calls the main view-controller index.js. If an initializer file, alloy.js, exists, the entire contents of the file are copied into the app.js file right before the call to initiate the main view-controller.
Before the file is written to the Resources directory, the 'compile:app.js' task executes if one is defined in the build configuration file.
The generated code is processed through UglifyJS to optimize the code for speed and compactness. The code is optionally beautified.
If the code is compiled for a specific platform, all conditional code that should not be executed for that platform is removed. For example, if the application contains code sections specifically for iOS but the application is compiled for an Android platform, all of the iOS conditional code is removed.
Required Alloy builtin libraries are copied to the Resources/<platform>/alloy folder and optimized in the same process as described before.
Then, the 'post:compile' task executes if one is defined in the build configuration file.