在dojo构建配置文件中包含一个普通的javascript文件

时间:2013-04-29 02:57:51

标签: javascript build dojo amd

我正在构建dojo 1.8.3,其配置文件将所有dojo和我自己的AMD代码放在一个单独的层中。我还希望在同一个文件中包含一些非AMD库(例如history.js)和polyfill。是否可以使用dojo构建系统执行此操作?

当前版本配置文件:

var profile = (function () {
var conf = {
    basePath: ".",
    layerOptimize: "closure",
    optimize: "closure",
    cssOptimize: "comments",
    mini: true,
    selectorEngine: "acme",

    defaultConfig: {
        hasCache: {
            "dojo-built": 1,
            "dojo-loader": 1,
            "dom": 1,
            "host-browser": 1,
            "config-selectorEngine": "acme"
        },
        async: 1
    },

    packages: [{
        name: "dojo",
        location: "./dojo"
    }, {
        name: "dijit",
        location: "./dijit"
    }, {
        name: "dojox",
        location: "./dojox"
    }, {
        name: "MyApp",
        location: "./MyApp"
    }, {
        name: "bootstrap",
        location: "./bootstrap"
    }],

    layers: {
        "dojo": {
            name: "dojo",
            include: [
                "dojo/dojo",
                "dojo/domReady",
                "MyApp/common",
                "MyApp/bootstrap"
            ]
        }
    }
}
return conf;
}());

1 个答案:

答案 0 :(得分:1)

如果将文件作为包添加,dojo将自动包装它们并包含它们。我将其添加到包部分:

{
    name: "libs",
    location: "./libs"
}

并将图层定义更改为:

"dojo": {
     name: "dojo",
     include: [
         "dojo/dojo",
         "dojo/domReady",
         "libs/history/native.history",
         "libs/base64/base64",
         "MyApp/common",
         "MyApp/bootstrap"
     ]
 }    

(base64和native.history是普通的Javascript库)