Build 如何在dojo构建层中包含所有文件?

Build 如何在dojo构建层中包含所有文件?,build,dojo,Build,Dojo,我的个人资料定义如下: var profile = { .... layers: { "dojo/dojo": { include: ["dojo/main" ], customBase: true, boot: true } , "my/widget": { include: [ "my/widget/AuthorWidget"

我的个人资料定义如下:

var profile = {
    ....
    layers: {
       "dojo/dojo": {
            include: ["dojo/main" ],
            customBase: true,
            boot: true
        }
       , "my/widget": { include: [ 
                 "my/widget/AuthorWidget",
                 "my/widget/templates/AuthorWidget.html" ] 
       }
    },
....
}
define([
    "dojo/_base/declare",
    "dijit/_WidgetBase",
    "dijit/_TemplatedMixin",
    "dojo/text!./templates/AuthorWidget.html",
    "dojo/dom-style",
....
这正是我想要的。它创建了dojo.js和widget.js文件,其中包括我需要的所有文件

有没有更好的方法来包含my/widget中的所有文件,而不在include:中列出它们?AuthorWidget.js如下所示:

var profile = {
    ....
    layers: {
       "dojo/dojo": {
            include: ["dojo/main" ],
            customBase: true,
            boot: true
        }
       , "my/widget": { include: [ 
                 "my/widget/AuthorWidget",
                 "my/widget/templates/AuthorWidget.html" ] 
       }
    },
....
}
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
示例(此文件可以手动或使用一些定制工具进行更新):

在您的
profile.js
中,仅包含
all.js

var profile = {
    ....
    layers: {
       "dojo/dojo": {
            include: ["dojo/main" ],
            customBase: true,
            boot: true
        }
       , "my/widget": { include: [ 
                 "all"
          ] 
       }
    },
....
}

嗨,谢谢你的回答。这适用于AuthorWidget.js,但不适用于my/widget/templates/AuthorWidget.html。在authorWidget.html中,按钮具有数据dojo type=“dijit/form/button”属性,结果中不包括dijit/form/button。如果我在profile.js/include数组中保留“my/widget/templates/AuthorWidget.html”,那么它就可以工作了。如果我将它移动到all.js,它不会…@Petr尝试在你的.profile.js上设置包属性。你需要在那里为dijit指定正确的路径。更多关于所有选项的信息可以在这里找到:让我们知道你是否能够修复它:)我已经阅读了这篇文章,我不知道什么可能是错误的。正如我所说,将“my/widget/templates/AuthorWidget.html”放入my.profile.js中是正确的(将dijit/form/Button包含在result widget.js中)。但是将它从my.profile.js移动到all.js,它会停止包含dijit/form/Button。它适用于AuthorWidget中的所有其他依赖项-它甚至在结果中包含AuthorWidget.html的内容。@Petr当生成解决您的模块时,它看起来像一个问题。你能发布你的.profile.js的完整版本和你项目的文件夹结构吗?我可以试着看一看,我发现问题出在哪里了。我在AuthorWidget.js文件中不需要dijit/form/Button。它需要一个模板中使用的所有小部件(而不是期望parsr.parse()下载它)