I just switched to play framework 2.10 and like to use RequireJS. I do have a custom folder structure though (too lazy to write javascripts all the time, so its /js/ ;). while dist I then get the following error:
Error: ERROR: module path does not exist: /tmp/build_udsbfo9u2iwl/target/scala-2.10/classes/public/javascripts/app.js for module named: app. Path is relative to: /tmp/build_udsbfo9u2iwl [info] RequireJS optimization finished.
So require is obviously looking only in javascripts folder. i guess there must be some place where the folder is configured, but i was unable to find it.
So, how can I configure requireJs in play framework 2.10 to use my folders while optimization?
Set the requireJsFolder value in Build.scala:
import sbt._
import Keys._
import play.Project._
object ApplicationBuild extends Build {
val appName = "play-2-1-features"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
jdbc,
anorm,
"junit" % "junit-dep" % "4.11" % "test"
)
val main = play.Project(appName, appVersion, appDependencies).settings(
requireJs += "main.js"
, requireJsFolder := "js" //changes location from javascripts to js
)
}
Then you can use it in your templates:
@helper.requireJs(core = routes.Assets.at("javascripts/require.js").url, module = routes.Assets.at("js/main").url)
Here is my example project https://github.com/schleichardt/play-2.1-features/tree/stackoverflow-question-14924134 (note: it is not in master branch)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With