Grunt构建成功,但requirejs相关库不可用

问题

我有一个成功完成的grunt构建,除了依赖于其他库的那些库之外,大多数库都可用。

例如,underscore-string依赖于下划线,并将其自身作为_.string附加到下划线名称空间,但该功能在应用程序中不可用。 这与我遇到同样的问题。

RequireJS配置

{
 "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"
   ...
  ]
}

笔记

该应用程序工作正常,并且字符串和范围库都包含在最终的构建文件中。 我的猜测是,加载构建文件后,下划线和时刻库不可用于附加。


解决它 - 下划线字符串需要被包含为“underscore.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"
  ...       
},
链接地址: http://www.djcxy.com/p/93631.html

上一篇: Grunt build successful but requirejs dependent libraries unavailable

下一篇: IOS Device Logs