问题
I've a problem trying to create a custom build on Dojo, I dont even know is it possible what I want..
I want to have a "single js file" loading all the components that i use across the application. so it doesnt load several files just one containing what I need, or at least just the ones I need.
As far as I read I need to create a Profile for this build, this is the profile I use (file in profiles folder ex: test.profiles.js).
dependencies ={
layers: [
{
name: "test_dojo.js",
customBase: true,
selectorEngine: "acme",
dependencies: [
"dojo/dojo",
"dijit.form.Form",
"dijit.form.Button",
"dijit.form.Textarea",
"dojo.parser",
"dijit.form.MultiSelect",
"dijit.layout.ContentPane",
"dijit.layout.BorderContainer",
"dijit.Toolbar",
"dijit.form.TextBox",
"dijit.form.SimpleTextarea",
"dijit.form.ComboBox",
"dojo.date",
"dojo.date.locale",
"dijit.form.DateTextBox",
"dijit.layout.TabContainer",
"dojo.data.ItemFileReadStore",
'dijit.Dialog',
"dojox.grid.DataGrid",
"dijit.form.DropDownButton",
"dijit.form.CheckBox",
"dijit.form.FilteringSelect",
"dijit.form.NumberTextBox",
"dijit.Tree",
"dojox.charting.Chart2D",
"dojox.charting.widget.Legend",
"dojox.charting.action2d.Tooltip",
"dojox.charting.action2d.Magnify",
"dojox.charting.themes.PlotKit.green",
"dojox.charting.themes.PlotKit.red",
"dojox.charting.themes.PlotKit.blue",
"dojox.widget.Standby",
"dojox.form.Uploader",
"dojox.form.uploader.plugins.IFrame",
"dojox.form.uploader.FileList",
"dijit.ProgressBar",
"dojox.embed.Flash",
"dijit.Tooltip",
"dojox.cometd",
"dijit._base.scroll"
]
}
],
prefixes: [
[ "dijit", "../dijit" ],
[ "dojox", "../dojox" ]
]
};
I ran it this way: > build.bat profile=test action=release
this generates me the folder "release" inside if this I find dojo -> dojo, dijit, dojox folder and inside dojo -> test_dojo.js
I copy the content of the release into the application and replace the script tag in the html files.
<script src="/dojo_release/dojo/test_dojo.js" type="text/javascript"
djconfig="usePlainJson: true,parseOnLoad: true"></script>
but get the error: "dojo is not defined in line 14"
and if I try to load the dojo and then this file:
<script src="/dojo_release/dojo/dojo.js" type="text/javascript"
djconfig="usePlainJson: true,parseOnLoad: true"></script>
<script src="/dojo_release/dojo/psirt_dojo.js" type="text/javascript"></script>
I debug the application and get that is trying to load several files (as it used to) and get errors such as "Could not load 'dijit.form.Form'; last tried '../dijit/form/Form.js'"
this maybe a basic question im quiet new with dojo and more with the custom build stuff.
Do I have correct the profile or what could be the problem here, what am I doing wrong.
回答1:
You do not need the 'customBase' flag to do this. You can simply override the dojo.js file with its current contents _plus some cached modules of your own.
dependencies ={
selectorEngine: "acme",
layers: [
{
name: "../dojo/dojo.js",
dependencies: [
...
]
}
}
来源:https://stackoverflow.com/questions/11917391/dojo-custom-build-1-6-into-a-single-file