我一直在努力学习基于 AMD 的 Dojo 构建系统。到目前为止,我还无法获得一个可用的构建,而不会在浏览器 (FF) 中出现加载错误。
我对如何管理构建有疑问。
我的构建配置文件有一个包部分。我在那里指定的内容似乎与写入目标目录的相同包目录直接相关。这似乎很合适。但是,我还有一个图层部分,它试图仅合并来自 dojo、dijit、dojox 等的“引用”模块。当它们合并到一个 dojo.js 文件中时,我的目标目录中仍然有所有这些库目录. 您是否理解您只是手动进入并删除它们,或者是否有一种自动方法可以在构建过程中将它们删除?
在我的第一层中,我尝试为 dojo、dijit 和 dojox/app/main 构建它。这不会拉取任何资源,例如 dojo/resources/blank.gif 或同一目录中的任何 .css 文件。如何将这些资源文件复制到目的地?我相信 dojo.profile.js (确实表明要复制这些资源)只会影响 dojo 目录。但是由于我正在创建一个结合了 js 模块的自定义 dojo/dijit/dojox 文件,所以没有资源目录。在自定义构建之后,我是否应该手动进入 dojo 目录并将 dojo/resources 目录移出但扔掉 dojo 目录的其余部分?只是不确定如何在构建 dojo/dijit 层时获取 dojo 目录中可访问的依赖 img 和 css 文件,以便与自定义 dojo.js 层文件一起使用。
这是我的构建配置文件:
var profile = {
basePath: "./",
//releaseDir: "irb-release",
action: "release",
cssOptimize: "comments",
stripConsole: 'all',
selectorEngine: 'acme',
layerOptimize: 'closure',
optimize: 'closure',
mini: true,
packages:[
{ name: "dojo", location: "../libs/dojo" },
{ name: "dijit", location: "../libs/dijit" },
{ name: "dojox", location: "../libs/dojox" },
{ name: "dgrid", location: "../libs/dgrid" },
{ name: "put-selector", location: "../libs/put-selector" },
{ name: "xstyle", location: "../libs/xstyle" },
{ name: "myPkg", location: "../libs/myPkg" },
{ name: "irb", location: "../irb" }
],
layers: {
"release/irb/libs/dojo": {
include: ["dojo/dojo", "dijit/dijit", "dojox/app/main"],
boot: true,
customBase: true
},
"release/irb/libs/myPkg": {
include: [
"myPkg/dialog/MessageBox",
"myPkg/grids/FilterGrid",
"myPkg/util/WidgetMonitor",
"myPkg/controllers/BorderLayout",
"myPkg/controllers/UnloadViewController"
],
includeLocales: [ 'en-us' ]
},
"release/irb/libs/store/Memory": {
include: [ "dojo/store/Memory" ]
},
"release/irb/libs/store/Observable": {
include: [ "dojo/store/Observable" ]
},
"irb/irb": {
include: [
"irb/irb",
"dojox/app/View",
"dojox/css3/transit",
"dojox/app/controllers/Load",
"dojox/app/controllers/Transition",
"dojox/app/controllers/History"
]
}
},
staticHasFeatures: {
// The trace & log APIs are used for debugging the loader, so we do not need them in the build.
'dojo-trace-api': 0,
'dojo-log-api': 0,
// This causes normally private loader data to be exposed for debugging. In a release build, we do not need
// that either.
'dojo-publish-privates': 0,
// This application is pure AMD, so get rid of the legacy loader.
'dojo-sync-loader': 0,
// `dojo-xhr-factory` relies on `dojo-sync-loader`, which we have removed.
'dojo-xhr-factory': 0,
// We are not loading tests in production, so we can get rid of some test sniffing code.
'dojo-test-sniff': 0
}
};
更新:这是我的目录结构,大约是。基于 dojox/app 结构:
/(webroot)
/irb
/controllers
/res
/css
/img
/views
build.sh
config.json
index.html
irb.js
package.js
package.json
release.profile.js
/libs
/dgrid
/dijit
/dojo
/dojox
/myPkg
/put-selector
/util
/xstyle
对于构建,我使用基于 dojox/app 示例的 build.sh 文件,但它调用的内部命令行是:
node "/home/(user)/(project ... path)/(webroot)/libs/dojo/dojo.sh"
load=build
--require "/home/(user)/(project ... path)/(webroot)/irb/irb.js"
--profile "/home/(user)/(project ... path)/(webroot)/irb/release.profile.js"
--appConfigFile "/home/(user)/(project ... path)/(webroot)/irb/config.json"
--releaseDir "/home/(user)/(project ... path)/(webroot)/build"