What is a build?
In one sentence: a build regroups of all JS files in order to reduce the calls made to the servers.
How to create a build?
In theory a build is very simple to set up: you set all the JS classes used by your site in a profile.js file and then you call a script with the options of your choice and the build is done. But in practice it is more complicated, as it is not always easy to understand the interconnections between the different elements.
Step 0: prerequisite
Step 1: Download sources Dojo
The basic version of Dojo provides 3 folders; Dojo, Dijit and Dojox. It lacks a critical folder called as: "util". This folder contains all the tools to create our build.
Step 2: Prepare your classes
This step is simple but critical: you must identify the names of all your JS class declared in Dojo [all the "dojo.provide("myfolder1.myfolder2.MyClass")].
For each of these classes, note:
- the name ("myfolder1.myfolder2.MyClass")
- Its relative path from the "buildscripts" folder.
Step 3: Create your profile.js file
- Now that you have the class names and classpaths, go to the "buildscripts" > "Pofiles" folder.
- Several profiles already exist, create a new one based on the existing baseplus.profile.js and then rename it as myprofil.profile.js;
- The Baseplus profile contains a single layer and the two paths (code) needed for this layer. Now it is very simple:
- keep the dojo.js layer and replace the class name by yours.
- add prefixes to all your paths (example : "myfolder1.myfolder1 : "../../myfolder1/myfolder1")
Make sure that your prefixes point to the right folder!
Step 4: Create a release folder
- Go back to the root folder where you unzipped the archive (the one with dojo, dijit, dojox and util) and create a new folder called: "release". This folder will contain all the files created by Dojo.
Step 5: Start the build
- Run the script in command line:
- Windows: Start - Run - cmd
- In the console that opens, navigate to buildscripts file using the command "cd <mydirectory>".
- Once in the buildscript folder, run the following command:
You can launch build.bat with various options:
- profile: the profile file that you created.
- releaseDir: relative path to the release folder created.
- action: Here we clean the release folder and makes a new one.
- releaseName: name of your release (Version 1.0 for example)
- cssOptimize: "comments - all CSS comments will be removed and compress everything.
- optimize: "shrinksafe" request the build to compress the final JS files.
All options are listed here: http://dojotoolkit.org/reference-guide/1.8/build/buildScript.html#build-buildscript
Step 6: Copy your sources
Once the build is complete, return to your release folder: It normally contains multiple folders and a copy of each file that you entered in the profile.js via prefixes. This is normal.
Published by deri58
Latest update on April 25, 2013 at 09:42 AM by deri58.