Play 2.4, Webjars not able to locate bootstrap

2.1k views Asked by At

I'm attempting to use the Play webjars helper according to the documentation here to load Bootstrap: http://www.webjars.org/documentation

However when requesting the page I'm getting the following exception:

[IllegalArgumentException: css/bootstrap.min.css could not be found. Make sure you've added the corresponding WebJar and please check for typos.]

build.sbt

libraryDependencies ++= Seq(
...
  "org.webjars" %% "webjars-play" % "2.4.0-1",
  "org.webjars" % "bootstrap" % "3.3.4",
...
)

routes

#WebJars wrapper
GET        /webjars/*file        controllers.WebJarAssets.at(file)

html

...
<link rel='stylesheet' href='@routes.WebJarAssets.at(WebJarAssets.locate("css/bootstrap.min.css"))'>
...

This same html file also uses the webjars wrapper to locate require.min.js, which works without problem.

<script data-main="@routes.Assets.versioned("javascripts/main.js")"
src="@routes.WebJarAssets.at(WebJarAssets.locate("require.min.js"))"></script>

If I instead load Bootstrap using Plays reverse routing like so, it works:

<link rel='stylesheet' href='@routes.Assets.versioned("lib/bootstrap/css/bootstrap.min.css")'>

Any ideas why the webjars helper is unable to load Bootstrap, but is able to load require.min.js?

The easiest solution for now seems to be to ditch the webjars wrapper altogether, as it does not really seem to make it easier or more readable when loading resources.

0

There are 0 answers