Interesting to see all the command line params mixed as part of the
dependency objects ... I've only used that for kwArgs buildExclude
stuff. Would definitely cleanup some command lines of mine if I started
doing it this way :)
Matthew Weier O'Phinney wrote:
> -- Drew Bertola <drew@drewb.com> wrote
> (on Saturday, 27 December 2008, 10:55 PM -0800):
>
> * Create a layer file that contains all your dojo.require() statements:
> In public/js/<your custom module>/main.js (I'll call it "custom"):
>
> dojo.provide("custom.main");
>
> (function(){
> dojo.require("dijit.form.Form");
> dojo.require("dijit.form.Button");
> /* etc. */
> })();
>
>
Just as a note, put the dojo.require calls above the closure, and use
the anon function to scope stuff locally for that module. When the build
runs, executing the code from form.FOrm and form.Button within the
(function(){ })() is unnecessary overhead (though trivial). It also
seems "cleaner" to me:
dojo.provide("my.thinger");
dojo.require("my.otherthinger");
(function(){
// do stuff
var d = dojo; d.addOnLoad(function(){ ... });
})();
The way the build works (in the x-domain case) may be affected if the
require calls are not "outside" of the closure there, as special
consideration in the loader is taken to ensure all the modules are
tracked synchronously and whatnot.
> * In your bootstrap, make sure you reference this layer file:
>
> $view->dojo()->requireModule("custom.main");
>
> * Create a profile: public/js/util/buildscripts/profiles/custom.profile.js
>
> /* ./build.sh profile="custom" */
> dependencies = {
> action: "release",
> version: "1.2.2-custom", /* this can be arbitrary */
> releaseName: "custom",
> loader: "default",
> cssOptimize: "comments.keepLines",
> optimize: "shrinksafe",
> layerOptimize: "shrinksafe",
> copyTests: false,
> layers: [
> {
> name: "../custom/main.js",
> layerDependencies: [],
> dependencies: [
> "custom.main",
> ]
> }
> ],
> prefixes: [
> [ "dijit", "../dijit" ],
> [ "dojox", "../dojox" ],
> [ "custom", "../custom" ]
> ]
> }
>
> * From within public/js/util/buildscripts, execute:
>
> $ ./build.sh profile="custom"
>
> * The build will be created in public/js/release/custom
>
> * Now replace public/js with public/js/release/custom, and you'll be
> set.
>
> You'll need to clear your browser cache to notice the changes.
>
>
Regards,
Peter Higgins
没有评论:
发表评论