*Only the application's local files will be inlcuded in the build output. No Esri or Dojo AMD modules will be included. The output application will still need a script tag that references the Dojo loader inlcuded in Esri's CDN copy of the JSAPI.
NOTE: this boilerplate is a work in progress, but is relatively stable. See the Known Issues section below
Running the Examples
- Fork and clone the repo
git submodule initand
git submodule update
- Instal the dependancies with
- Run a Grunt build with one of the following options:
grunt compileto minify each AMD module into it's own file
grunt singleto build a single file that contains all the minified AMD modules and their templates as inlined text
- Inspect and/or browse to the contents to of the
How It Works
r.js is the AMD optimizer for RequireJS, and @robertd got it working for basic Dojo AMD modules, but there's always been issues with modules that use plugins (such as dojo/text to pull in template files).
@odoe figured out how to use the RequireJS plugins during the build process but use the Dojo plugins at runtime by:
- Including the requireJS text/domReady plugins in the project (as git submodules in this case)
- Referencing the above plugins in all modules by replacing
- Adding aliases to the Dojo config to point the above reference back to the Dojo plugins as follows:
aliases: [['text', 'dojo/text'], ['domReady', 'dojo/domReady'], ['i18n', 'dojo/i18n']]
The above worked for a multi-file build, but there were still issues with inlining text (templates) when creating a single-file build. @odoe figured out how to do a quick find and replace on the built file using
grunt-contrib-text-replace that enabled the Dojo loader to load the built templates.
NOTE: Whenever there is more than one way to accomplish a build step, the examples in this repo give preference to doing things the r.js way. For example, it's possible to use
grunt-contrib-cssmin to minify and concatenate CSS files, but the examples in this repo let r.js do it (using
cssIn in the case of the single-file build).
The build configurations have not been tested against app code that uses the
has plugin, and it is likely to fail. In theory, it is possible to bring the include the requireJS
has plugin as a git submodule, and alias the
dojo/has the way the other plugins have been. If your project uses
has we invite you to fork, test, and submit a pull request if it works!
Copyright (c) 2013 Robert Djurasaj
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.