我正在一个带有骨干样板的项目中工作,该项目使用 RequireJS 加载模块和 JamJS 来管理它们。我的要求config.js
文件如下:
require.config({
deps: ["../vendor/jam/require.config", "main"],
paths: {
"backbone.localStorage": "../vendor/backbone.localStorage-1.0/backbone.localStorage"
},
shim: {
"backbone.localStorage": {
deps: ['backbone']
}
}
});
如您所见,来自 jam 配置文件的 RequireJS 加载配置jam/require.config.js
指定了主干、jquery 和下划线。接下来是一段文件:
"packages": [
{
"name": "backbone.layoutmanager",
"location": "../vendor/jam/backbone.layoutmanager",
"main": "backbone.layoutmanager.js"
}
{
"name": "backbone",
"location": "../vendor/jam/backbone",
"main": "backbone.js"
}
],
"version": "0.2.11",
"shim": {
"backbone.layoutmanager": {
"deps": [
"jquery",
"backbone",
"lodash"
],
"exports": "Backbone.LayoutManager"
}
"backbone": {
"deps": [
"jquery",
"lodash"
],
"exports": "Backbone"
}
}
};
我想要在我config.js
的主干.localStorare 库中指定取决于包部分中定义的主干。此外,如果我按如下方式指定主干路径,那么它会找到主干库,但会发现一条错误消息,指出未加载下划线:
require.config({
deps: ["../vendor/jam/require.config", "main"],
paths: {
"backbone": "../vendor/jam/backbone/backbone",
"backbone.localStorage": "../vendor/backbone.localStorage-1.0/backbone.localStorage"
},
shim: {
"backbone.localStorage": {
deps: ['backbone']
}
}
});
我可以使用 jamjs 添加backbone.localStorage 库,但是可用包的版本很旧,所以我更喜欢手动下载最后一个并手动包含。
任何想法或帮助将不胜感激。