My setup used org.webjars.webjars-play.2.5.0
with Scala Play 2.5. I was using couple of WebJars libraries for different purposes and ended with 2 jquery.min.js
files located in 2 directories, target/web/web-modules/main/webjars/lib/jquery
and target/web/web-modules/main/webjars/lib/jquery/dist
.
When I accessed the index web page, an exception [IllegalArgumentException: jquery/jquery.min.js could not be found
was thrown by <script type="text/javascript" src="@routes.WebJarAssets.at(webJarAssets.locate("jquery/jquery.min.js"))"></script>
even though the file existed at target/web/web-modules/main/webjars/lib/jquery/jquery.min.js
. I tried different path lib/jquery/jquery.min.js
to locate the script but unsuccessful. However, when dist/jquery.min.js
is used, it can find the script but it is the version I wanted.
How do I configure to help WebJarAssests to locate the jquery.min.js
in target/web/web-modules/main/webjars/lib/jquery
? How do I stop other WebJars from loading a different versions of jquery.min.js
into my project? Thanks
Meanwhile, I am using <script type="text/javascript" src="@routes.Assets.at("lib/jquery/jquery.min.js")"></script>
to get things going.
Update 1
Current setup,
class ApplicationController @Inject() (
val webJarAssets: WebJarAssets,
val silhouette: Silhouette[CookieAuthenticatorEnv],
...
) extends AuthController {...}
@(webJarAssets: WebJarAssets, ...)(implicit messages: Messages)
GET /webjars/*file controllers.WebJarAssets.at(file)
You can either use the regular Play Static Asset stuff + sbt-web to use the target/web/web-modules/main/webjars/lib
files, or you can use the WebJarAssets
thing. More details in the docs.
To use WebJarAssets
, instead of:
webJarAssets.locate("jquery.min.js")
Try:
webJarAssets.locate("jquery", "jquery.min.js")