I have a multi-module Play Framework project with two modules, common
which is a standard project containing reusable code and assets, and app
which is the play project I am trying to run. Using the Sbt-Web plugin, I am able to create and modify assets in common/src/main/public
which are copied into the folder app/target/web/web-modules/main/webjars/lib/common
each time the app reloads. My issue is with referencing these assets in my Play views. My routes
file includes the lines
GET /assets/*file controllers.Assets.at(path="/public", file)
GET /webjars/*file controllers.WebJarAssets.at(file)
and I'm trying to access these exported assets in my index.scala.html
file in app
by e.g.
<link rel="stylesheet" media="screen" href="@routes.WebJarAssets.at(WebJarAssets.locate("common/css/directives.css"))">
This file does exist at app/target/web/web-modules/main/webjars/lib/common/css/directives.css
but WebJarAssts.locate
returns
{"status":{"errors":[{"message":"common/css/directives.css could not be found. Make sure you've added the corresponding WebJar and please check for typos."}]}}
I have tried specifying more and less of the path and also to access it as a standard asset via Assets.at
, but no luck. Does anyone know how to reference exported assets properly?
Relevant lines from my build.sbt
file are
val playVersion = play.core.PlayVersion.current
lazy val common = project.enablePlugins(SbtWeb, SbtTwirl).settings(
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play" % playVersion % "provided",
)
)
lazy val app = project.enablePlugins(PlayJava).settings(
libraryDependencies ++= Seq(
"org.webjars" %% "webjars-play" % "2.3.0"
)
).dependsOn(common % "compile->compile;test->test")
lazy val suite = project.in(file(".")).aggregate(common, app)