我有一个定义如下的配置文件:
var profile = {
....
layers: {
"dojo/dojo": {
include: ["dojo/main" ],
customBase: true,
boot: true
}
, "my/widget": { include: [
"my/widget/AuthorWidget",
"my/widget/templates/AuthorWidget.html" ]
}
},
....
}
这就是我想要的。它创建文件dojo.js和widget.js,其中包括我需要的所有内容。
有什么更好的方法可以包括我/小工具中的所有文件,而不必在include:中列出它们?AuthorWidget.js看起来像这样:
define([
"dojo/_base/declare",
"dijit/_WidgetBase",
"dijit/_TemplatedMixin",
"dojo/text!./templates/AuthorWidget.html",
"dojo/dom-style",
....
因此,我希望包括my / widget / templates / AuthorWidget.html中的所有依赖小部件。不幸的是,我在include:数组中有此文件,否则结果中不包含dijig / form / Button。(我在AuthorWidget.html中具有[button type =“ button” data-dojo-type =“ dijit / form / Button”]单击我![/ button])
my.profile.js:
var profile = (function(){
return {
basePath: "./src",
releaseDir: "../release",
releaseName: "my",
action: "release",
defaultConfig: {
async: 1
},
packages:[{
name: "dojo",
location: "dojo"
},{
name: "dijit",
location: "dijit"
},{
name: "dojox",
location: "dojox"
},{
name: "my",
location: "../js/my",
destLocation: "myapp"
}],
layers: {
"dojo/dojo": {
include: ["dojo/main" ],
customBase: true,
boot: true
}
//this works
//, "my/widget": { include: [ "my/widget/AuthorWidget", "my/widget/templates/AuthorWidget.html" ] }
//this doesnt include Button widget required by AuthorWidget.html
, "my/widget": { include: [ "my/widget/all" ] }
},
layerOptimize: "closure",
optimize: "closure",
cssOptimize: "comments",
mini: true,
stripConsole: "warn",
selectorEngine: "lite"
};
})();
据我所知,直接回答您的问题。您需要以一种或另一种方式列出您的依赖项。
但是您可以创建一个all.js
文件,该文件基本上是一个模块,可以包含您的自定义窗口小部件的所有依赖项。
这为您提供了将依赖项定义保留在外部的优势.profile.js
。
例如,可以all.js
使用定制工具自动创建用法,因此在应用程序中创建模块时,您无需手动更新所有依赖关系及其路径。
的示例all.js
(此文件可以手动或使用某些定制工具进行更新):
require([
'my/widget/AuthorWidget',
'my/widget/AuthorWidget2,
...
]);
profile.js
仅包含在您的内容中all.js
:
var profile = {
....
layers: {
"dojo/dojo": {
include: ["dojo/main" ],
customBase: true,
boot: true
}
, "my/widget": { include: [
"all"
]
}
},
....
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句