我一直在努力学习基于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目录中访问依赖的img和css文件,以便在构建dojo / dijit层时与自定义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"
答案 0 :(得分:2)
额外文件和目录
我认为不删除它们是一种好习惯。执行构建的原因是通过将所有内容组合到一些(最好是一个)javascript文件中来提高Web浏览器的性能。
但是如果使用的文件(模块)未包含在图层中会发生什么。如果构建目录中有其他文件,则应用程序仍然可以工作,您只需要另外调用服务器即可获取该文件。如果您删除了这些目录和文件,您的应用程序将会中断。
提取资源
完成自定义构建后,我有一个
release/RELEASE_NAME/dojo/resources
目录,其中包含您提到的所有资源。
编辑:添加示例......
示例强>
命令
node path/to/dojo/dojo.js
load=build --profile path/to/build.profile.js --release --version=1.9.0
build.profile.js
var profile = (function(){
return {
// Assuming that the node command is being run in
// the webroot directory. If not, update the basePath
// to the libs directory using the current directory as
// the starting point.
basePath: "./libs",
releaseDir: "/path/to/release/dir",
action: "release",
releaseName: "release",
layerOptimize: "shrinksafe",
optimize: false,
cssOptimize: "comments",
mini: false,
stripConsole: "normal",
selectorEngine: "acme",
packages:[
{name: 'dojo', location: 'dojo'},
{name: 'dijit', location: 'dijit'},
{name: 'dojox', location: 'dojox'},
{name: 'dgrid', location: 'dgrid'},
{name: 'put-selector', location: 'put-selector'},
{name: 'xstyle', location: 'xstyle'}
{name: 'irb', location: '../irb'},
],
layers: {
'irb/dojo": {
include: ["dojo/dojo", "dijit/dijit", "dojox/app/main"],
boot: true,
customBase: true
},
...
}
};
})();