How to use webjars! loader plugin?

只愿长相守 提交于 2019-12-07 18:42:01

问题


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.

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']);

    });

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.

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"
)  

回答1:


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

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.



来源:https://stackoverflow.com/questions/22242605/how-to-use-webjars-loader-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!