问题描述
在以前的Play应用中,我曾经使用过Webjars& RequireJS管理依赖项.我可以毫无疑问地使用require(['angular','webjars!ui-bootstrap-tpls.js'],function(angular){...}).
In my previous Play app, I used to use Webjars & RequireJS to manage dependencies. I could use require(['angular', 'webjars!ui-bootstrap-tpls.js'], function(angular) {...}) without problem.
最近我在www.webjars.org上将webjar和一些与webjar相关的部门(webjars-ui-bootstrap等)更新为最新版本,并找到了webjar!加载程序插件无法正常工作.我签出了webjars-seed-play应用程序,并修改了一些代码,例如:
Recently I updated webjars and several webjars related deps (webjars-ui-bootstrap, etc.) to the latest version on www.webjars.org, and I found webjars! loader plugin not working properly. I checked out the webjars-seed-play app and modified some code like:
require(['angular', './controllers', './directives', './filters', './services', 'angular-route', 'webjars!ui-bootstrap-tpls.js'],
function (angular, controllers) {
// Declare app level module which depends on filters, and services
angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives', 'ngRoute', 'ui.bootstrap']).
config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/view1', {templateUrl: 'partials/partial1.html', controller: controllers.MyCtrl1});
$routeProvider.when('/view2', {templateUrl: 'partials/partial2.html', controller: controllers.MyCtrl2});
$routeProvider.otherwise({redirectTo: '/view1'});
}]);
angular.bootstrap(document, ['myApp']);
});
它只是抱怨ui.bootstrap不可用,我认为应该由webjars!ui-bootstrap-tpls.js加载.我在这里做错了什么?请帮我.谢谢.
It just complains that ui.bootstrap is not available, which should be loaded by webjars!ui-bootstrap-tpls.js in my opinion. What am I doing wrong here? Please help me. Thanks.
我的build.sbt部门:
My deps in build.sbt:
libraryDependencies ++= Seq(
"org.webjars" %% "webjars-play" % "2.2.1-2",
"org.webjars" % "angularjs" % "1.2.13",
"org.webjars" % "bootstrap" % "3.1.1",
"org.webjars" % "requirejs" % "2.1.11-1",
"org.webjars" % "angular-ui-bootstrap" % "0.10.0"
)
推荐答案
很抱歉遇到麻烦.现在RequireJS已在WebJars中得到正式支持,我们必须进行一些更改: http://www.jamesward.com/2014/02/19/official-support-for-requirejs-in-webjars
Sorry about the hassle. Now that RequireJS is officially supported in WebJars we had to make some changes: http://www.jamesward.com/2014/02/19/official-support-for-requirejs-in-webjars
简而言之,webjars!
插件加载器已被普通的RequireJS模块和路径配置所取代.一些WebJars尚未更新.因此,如果您遇到问题,请向WebJar提出问题.
In short, the webjars!
plugin loader has been replaced with just normal RequireJS modules and path configs. Some of the WebJars haven't been updated yet. So if you run into problems please file an issue against the WebJar.
这篇关于如何使用webjars!加载程序插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!