Skip to content
This repository has been archived by the owner on Dec 31, 2017. It is now read-only.

Commit

Permalink
Update to Dojo 1.8.0, separate package & application profiles, change…
Browse files Browse the repository at this point in the history
… whitespace rules.
  • Loading branch information
csnover committed Aug 19, 2012
1 parent c952e71 commit f35c479
Show file tree
Hide file tree
Showing 19 changed files with 273 additions and 650 deletions.
18 changes: 8 additions & 10 deletions README.md
Expand Up @@ -3,10 +3,10 @@ Dojo Boilerplate: A Starter Kit for Dojo Development

The Dojo Boilerplate is a set of files to help you rapidly get up and running
with the Dojo Toolkit. It illustrates some basic best practices when working
with Dojo. This is the branch for the new Dojo 1.7 loader and build systems,
which use AMD modules; there is also a [branch using the old synchronous
loader](https://github.com/csnover/dojo-boilerplate/tree/1.6), for use
with Dojo 1.6.
with Dojo. This is the branch for the new AMD loader and build systems in Dojo
1.7 and later; there is also a
[branch using the old synchronous loader](https://github.com/csnover/dojo-boilerplate/tree/1.6),
for use with Dojo 1.6 and earlier.

Huge thanks go out to [neonstalwart](https://github.com/neonstalwart) for his
original
Expand Down Expand Up @@ -50,19 +50,17 @@ A brief tour
(by way of the second `[ 'app' ]` argument).
* The file `build.sh` takes your application files and builds them for
production use using the Dojo build tool. It depends on the presence of the
build profile at `src/app/app.profile.js`.
build profile at `profiles/app.profile.js`.
* The file `src/app/resources/app.css` contains import statements to load
the CSS for Dojo’s Claro theme. _If you are not using Dijit widgets, you
probably want to remove these imports!_
* The directory `src/dbp` contains tools you may find useful. These tools
are a work in progress, and are not yet updated to AMD syntax.

Useful resources
----------------

* [Dojo Reference Guide (latest release version)](http://dojotoolkit.org/reference-guide/)
* [Dojo Reference Guide (Dojo trunk)](http://livedocs.dojotoolkit.org/)
* [Introduction to Custom Dojo Widgets](http://www.enterprisedojo.com/2010/09/21/introduction-to-custom-dojo-widgets/)
* [Dojo Tutorials](http://dojotoolkit.org/documentation/)
* [Dojo Reference Guide](http://dojotoolkit.org/reference-guide/)
* [Dojo API Browser](http://dojotoolkit.org/api/)

About the boilerplate
---------------------
Expand Down
16 changes: 8 additions & 8 deletions build.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand All @@ -21,13 +21,13 @@ LOADERMID="app/run"
LOADERCONF="$SRCDIR/$LOADERMID.js"

# Main application package build configuration
PROFILE="$SRCDIR/app/app.profile.js"
PROFILE="$BASEDIR/profiles/app.profile.js"

# Configuration over. Main application start up!

if [ ! -d "$TOOLSDIR" ]; then
echo "Can't find Dojo build tools -- did you initialise submodules? (git submodule update --init --recursive)"
exit 1
echo "Can't find Dojo build tools -- did you initialise submodules? (git submodule update --init --recursive)"
exit 1
fi

echo "Building application with $PROFILE to $DISTDIR."
Expand All @@ -39,12 +39,12 @@ echo " Done"
cd "$TOOLSDIR"

if which node >/dev/null; then
node ../../dojo/dojo.js load=build --require "$LOADERCONF" --profile "$PROFILE" --releaseDir "$DISTDIR" "$@"
node ../../dojo/dojo.js load=build --require "$LOADERCONF" --profile "$PROFILE" --releaseDir "$DISTDIR" $@
elif which java >/dev/null; then
java -Xms256m -Xmx256m -cp ../shrinksafe/js.jar:../closureCompiler/compiler.jar:../shrinksafe/shrinksafe.jar org.mozilla.javascript.tools.shell.Main ../../dojo/dojo.js baseUrl=../../dojo load=build --require "$LOADERCONF" --profile "$PROFILE" --releaseDir "$DISTDIR" "$@"
java -Xms256m -Xmx256m -cp ../shrinksafe/js.jar:../closureCompiler/compiler.jar:../shrinksafe/shrinksafe.jar org.mozilla.javascript.tools.shell.Main ../../dojo/dojo.js baseUrl=../../dojo load=build --require "$LOADERCONF" --profile "$PROFILE" --releaseDir "$DISTDIR" $@
else
echo "Need node.js or Java to build!"
exit 1
echo "Need node.js or Java to build!"
exit 1
fi

cd "$BASEDIR"
Expand Down
107 changes: 107 additions & 0 deletions profiles/app.profile.js
@@ -0,0 +1,107 @@
/**
* This is the default application build profile used by the boilerplate. While it looks similar, this build profile
* is different from the package build profile at `app/package.js` in the following ways:
*
* 1. you can have multiple application build profiles (e.g. one for desktop, one for tablet, etc.), but only one
* package build profile;
* 2. the package build profile only configures the `resourceTags` for the files in the package, whereas the
* application build profile tells the build system how to build the entire application.
*
* Look to `util/build/buildControlDefault.js` for more information on available options and their default values.
*/

var profile = {
// `basePath` is relative to the directory containing this profile file; in this case, it is being set to the
// src/ directory, which is the same place as the `baseUrl` directory in the loader configuration. (If you change
// this, you will also need to update run.js.)
basePath: '../src/',

// This is the directory within the release directory where built packages will be placed. The release directory
// itself is defined by `build.sh`. You should probably not use this; it is a legacy option dating back to Dojo
// 0.4.
// If you do use this, you will need to update build.sh, too.
// releaseName: '',

// Builds a new release.
action: 'release',

// Strips all comments and whitespace from CSS files and inlines @imports where possible.
cssOptimize: 'comments',

// Excludes tests, demos, and original template files from being included in the built version.
mini: true,

// Uses Closure Compiler as the JavaScript minifier. This can also be set to "shrinksafe" to use ShrinkSafe,
// though ShrinkSafe is deprecated and not recommended.
// This option defaults to "" (no compression) if not provided.
optimize: 'closure',

// We're building layers, so we need to set the minifier to use for those, too.
// This defaults to "shrinksafe" if not provided.
layerOptimize: 'closure',

// Strips all calls to console functions within the code. You can also set this to "warn" to strip everything
// but console.error, and any other truthy value to strip everything but console.warn and console.error.
// This defaults to "normal" (strip all but warn and error) if not provided.
stripConsole: 'all',

// The default selector engine is not included by default in a dojo.js build in order to make mobile builds
// smaller. We add it back here to avoid that extra HTTP request. There is also a "lite" selector available; if
// you use that, you will need to set the `selectorEngine` property in `app/run.js`, too. (The "lite" engine is
// only suitable if you are not supporting IE7 and earlier.)
selectorEngine: 'acme',

// Builds can be split into multiple different JavaScript files called "layers". This allows applications to
// defer loading large sections of code until they are actually required while still allowing multiple modules to
// be compiled into a single file.
layers: {
// This is the main loader module. It is a little special because it is treated like an AMD module even though
// it is actually just plain JavaScript. There is some extra magic in the build system specifically for this
// module ID.
'dojo/dojo': {
// In addition to the loader `dojo/dojo` and the loader configuration file `app/run`, we are also including
// the main application `app/main` and the `dojo/i18n` and `dojo/domReady` modules because, while they are
// all conditional dependencies in `app/main`, we do not want to have to make extra HTTP requests for such
// tiny files.
include: [ 'dojo/i18n', 'dojo/domReady', 'app/main', 'app/run' ],

// By default, the build system will try to include `dojo/main` in the built `dojo/dojo` layer, which adds
// a bunch of stuff we do not want or need. We want the initial script load to be as small and quick to
// load as possible, so we configure it as a custom, bootable base.
boot: true,
customBase: true
},

// In the demo application, we conditionally require `app/Dialog` on the client-side, so here we build a
// separate layer containing just that client-side code. (Practically speaking, you would probably just want
// to roll everything into a single layer, but this helps provide a basic illustration of multi-layer builds.)
// Note that when you create a new layer, the module referenced by the layer is always included in the layer
// (in this case, `app/Dialog`), so it does not need to be explicitly defined in the `include` array.
'app/Dialog': {}
},

// Providing hints to the build system allows code to be conditionally removed on a more granular level than
// simple module dependencies can allow. This is especially useful for creating tiny mobile builds.
// Keep in mind that dead code removal only happens in minifiers that support it! Currently, only Closure Compiler
// to the Dojo build system with dead code removal.
// A documented list of has-flags in use within the toolkit can be found at
// <http://dojotoolkit.org/reference-guide/dojo/has.html>.
staticHasFeatures: {
// The trace & log APIs are used for debugging the loader, so we do not need them in the build.
'dojo-trace-api': 0,
'dojo-log-api': 0,

// This causes normally private loader data to be exposed for debugging. In a release build, we do not need
// that either.
'dojo-publish-privates': 0,

// This application is pure AMD, so get rid of the legacy loader.
'dojo-sync-loader': 0,

// `dojo-xhr-factory` relies on `dojo-sync-loader`, which we have removed.
'dojo-xhr-factory': 0,

// We are not loading tests in production, so we can get rid of some test sniffing code.
'dojo-test-sniff': 0
}
};
10 changes: 5 additions & 5 deletions src/app/Dialog.js
@@ -1,10 +1,10 @@
/**
* This file is a very simple example of a class declaration in Dojo. It defines the app/Dialog module as a new
* This file is a very simple example of a class declaration in Dojo. It defines the `app/Dialog` module as a new
* class that extends a dijit Dialog and overrides the default title and content properties.
*/
define([ 'dojo/_base/declare', 'dijit/Dialog' ], function (declare, Dialog) {
return declare(Dialog, {
title: 'Hello World',
content: 'Loaded successfully!'
});
return declare(Dialog, {
title: 'Hello World',
content: 'Loaded successfully!'
});
});
129 changes: 0 additions & 129 deletions src/app/app.profile.js

This file was deleted.

0 comments on commit f35c479

Please sign in to comment.