我有一个成功完成的grunt构建,除了依赖于其他库的那些库之外,大多数库都可用。
例如,下划线字符串依赖于下划线,并将自身作为_.string附加到下划线名称空间,但该功能在应用程序中不可用。这与我在moment.range中遇到的问题相同。
{
"name": "app",
"dir": "client-compress",
"baseUrl": "client-dist",
"preserveLicenseComments": true,
"paths": {
"underscore": "bower_components/underscore/underscore",
"backbone": "bower_components/backbone/backbone-min",
"requireLib": "bower_components/requirejs/require",
"moment": "bower_components/moment/moment",
"string": "bower_components/underscore.string/lib/underscore.string",
"momentrange": "bower_components/moment-range/lib/moment-range"
...
},
"shim": {
"backbone": { "exports": "Backbone", "deps": ["underscore", "jquery"] },
"underscore": { "exports": "_" },
"string": { "deps": ["underscore"]},
"moment": {"exports": "moment"},
"momentrange": {"deps": ["moment"]}
...
},
"include": [
"requireLib",
"underscore",
"moment",
"string",
"backbone",
"momentrange"
...
]
}
应用程序工作正常未经优化,字符串和范围库都包含在最终构建文件中。我的猜测是,在加载构建文件后,下划线和时刻库无法附加。
答案 0 :(得分:1)
解决了 - 下划线字符串需要包含为“underscore.string”而不是“string”
然后配置的路径为
"paths": {
"underscore": "bower_components/underscore/underscore",
"backbone": "bower_components/backbone/backbone-min",
"requireLib": "bower_components/requirejs/require",
"moment": "bower_components/moment/moment",
"underscore.string": "bower_components/underscore.string/lib/underscore.string",
"momentrange": "bower_components/moment-range/lib/moment-range"
...
},