Dojo 如何使用r.js执行dijit优化?

Dojo 如何使用r.js执行dijit优化?,dojo,r.js,Dojo,R.js,在针对dijit通过r.js-o构建r.js时,我们如何避免文档未定义错误 具体来说,我正在尝试构建r-build.js: define(["require", "exports", "dijit/layout/ContentPane"], function (require, exports, ContentPane) { function simple() { return ContentPane; } return simple; }); 使用r.

在针对dijit通过r.js-o构建r.js时,我们如何避免文档未定义错误

具体来说,我正在尝试构建r-build.js:

define(["require", "exports", "dijit/layout/ContentPane"], function (require, exports, ContentPane) {
    function simple() {
        return ContentPane;
    }
    return simple;
});
使用r.js.cmd-o r-build.js并报告:

ReferenceError: document is not defined
In module tree:
    test/simple
      dijit/layout/ContentPane
        dijit/_Widget
          dojo/query
            dojo/selector/_loader
我的r-build.js文件如下所示:

({
    appDir: "../",
    baseUrl: "amd",
    dir: "../../release",
    optimize: "none",
    modules: [
        {
            name: "test/simple",
            exclude: ["jquery", "dojo"]
        }
    ],
    packages: [
            {
                name: 'cm',
                location: 'http://localhost:93/CodeMirror'
            },
            {
                name: 'jquery',
                location: 'd:/code/jquery/src',
                main: 'jquery'
            },
            {
                name: 'jquery/ui',
                location: 'http://localhost:93/jquery-ui/ui'
            },
            {
                name: 'jquery/themes',
                location: 'http://localhost:93/jquery-ui/themes'
            },
            {
                name: 'sizzle',
                location: 'http://localhost:93/jquery/external/sizzle/dist',
                main: 'sizzle'
            },
            {
                name: 'dojo',
                location: 'd:/code/dojo'
            },
            {
                name: 'dijit',
                location: 'd:/code/dijit'
            },
            {
                name: 'xstyle',
                location: 'http://localhost:93/xstyle'
            }
    ]
})

我在为同样的问题而斗争。用Dojo构建r.js包是一件痛苦的事情。 这个问题很容易解决。。。例如,如果ie9之前版本的支持浏览器没有问题,请覆盖该文件,并将检查querySelectorAll的行更改为true,这样就不需要进行这些检查。像

  has.add("dom-qsa2.1", true);
  has.add("dom-qsa3", true);

希望对您有所帮助……

仔细查看后,我发现query.js将selector/\u loader作为插件引用。/selector/\u loader!注意:插件及其依赖项应该能够在非浏览器环境中运行。显然这个dojo插件不能。似乎继续…解决这个问题并点击dojo/i18n…我猜r.js不能优化dojo。