Dojo: custom build hosted externally, locale error
I've created a custom build using the Dojo build tool including all the modules I'm using. This works great. However now that I've moved that build onto a CDN I'm getting an access control error when it tries to load the locale file:
开发者_StackOverflowXMLHttpRequest cannot load http://<CDN domain>/js/release/dojo/dojo/nls/custom-dojo_en-gb.js. Origin <site domain> is not allowed by Access-Control-Allow-Origin
Uncaught Error: Could not load 'dojo.nls.custom-dojo_en-gb'; last tried './nls/custom-dojo_en-gb.js'
How can I get it to load that file from the CDN domain instead? Or failing that, can I add a cross domain file to allow it to be loaded from the main domain?
The fix for this was for me to RTFM a little more closely! You can pass loader=xdomain to the build tool, along with the domain you want to bake into the build. You then reference dojo.xd.js instead of dojo.js and everything works great:
./build.sh profileFile=/path/to/profile.js action=clean,release loader=xdomain xdDojoPath=http://cdndomain/js/release/dojo releaseDir=/path/to/release
精彩评论