2016-08-15 62 views
2

Dojo配置支持requirejs bundlesdojo配置支持requirejs捆綁

在RequireJS 2.1.10中引入:允許在另一個腳本中配置多個模塊ID。例如:

requirejs.config({ 
    bundles: { 
     'primary': ['main', 'util', 'text', 'text!template.html'], 
     'secondary': ['text!secondary.html'] 
    } 
}); 

require(['util', 'text'], function(util, text) { 
    //The script for module ID 'primary' was loaded, 
    //and that script included the define()'d 
    //modules for 'util' and 'text' 
}); 

即配置狀態:模塊 '主', 'util的', '文本' 和 '!文本template.html' 將通過加載模塊ID來找到 '主要'。模塊'text!secondary.html'可以通過加載模塊ID'secondary'找到。

回答

2

在Dojo 1.8模塊被轉換爲AMD格式,但是dojo使用了一些仍然在草稿中並且可能與RequireJS不完全兼容的「特殊加載器插件」。在RequireJS文檔中,建議使用Dojo的AMD加載器。

Dojod bug tracker的相關文檔ticket 15616

請注意,如果您需要「構建」您的dojo應用程序,您應該使用dojo utilapp.profile.js,您可以在其中指定要「捆綁」的模塊列表。

我建議看看這個道場,樣板作爲起點,您的道場生成配置:https://github.com/csnover/dojo-boilerplate

在道場建立一個有用的資源,也可以在這裏找到:https://dojotoolkit.org/reference-guide/1.10/build/

+0

感謝信息,但我想使用dojo的amd加載器。我試圖弄清楚的是,如果dojoConfig對象支持requirejs加載器支持的「bundles」屬性。 –

+1

@MikeGraham公平地說,我知道dojoConfig沒有這樣的屬性,在文檔中沒有提及,如果你需要綁定你的dojo應用程序,你應該使用'util'。更多信息在這裏https://dojotoolkit.org/reference-guide/1.10/util/和這裏:https://dojotoolkitkit.org/reference-guide/1.10/dojo/_base/config.html – GibboK