Skip to content

Writing a custom profile

pruzand edited this page Jun 1, 2012 · 2 revisions

This page explains the various facilities the Dojo Build Factory (DBF) project provides when writing a new profile.

Profiles in DBF : overview

Doing a build of your web app (or a custom dojo distrib) allows to provide the best code packaging targeting specifically your needs. Coupled with the Google closure compiler, it allows to provide an optimized and efficient code for your web application without any useless dependencies and minimizing the amount of files and bandwidth. In Dojo, a build is configured via a configuration file called a profile. A profile is a javascript file that defines a profile variable that specifies the build properties. Please refer to The Dojo Build System reference for more information about the build system itself.

While DBF is fully compatible with the Dojo build profiles, it uses two different files, one that contains the "global" build properties (build/profiles/env-config.js) and a second one which is more focused on the layers contents. This approach makes easier writing layer definitions while the build properties don't change from one build to another. Therefore, writing a new profile in DBF usually means writing a new layer definition file. Hereafter, the term "profile" will refer to the layer definition file.

A profile must reside in the build/profiles directory, and is specified to the build process using the profileFile ant runtime property. For example, the following run the build to process the profile-mobile-FeP.js file: `ant -DprofileFile="profile-mobile-FeP"

Features

When writing layer definition files, it is common to reuse small set of a previous content. To make the writing easier, DBF introduces the concept of dependency entities, called features. A feature can be seen as a very specific minimal set of dependencies, that can then be referenced when writing the content of a layer.

For example, DBF comes with the common-ui feature (defined in build/profiles/features/common_ui.js) that defines a very small set of commonly-used dijit modules. It groups modules used by charting, mobile or calendar modules. Assuming you write an application that uses these dijit modules but don't want the full dijit layer, you could then write a new profile and define a layer that includes these common modules by simply including the feature.

Using a feature in a layer definition is done by means of the DBF-specific "use" function. This function takes a list of features to include in the layer. The following example shows how it is used to define the content of the core-web-layer layer:

"dojo/core-web-layer": {
    include: use("dojo_core_web", "common_ui")
},
Clone this wiki locally