Skip to content

Instantly share code, notes, and snippets.

@cessationoftime
Forked from drcharris/ConfigurableAssets.scala
Last active January 10, 2017 22:59
Show Gist options
  • Save cessationoftime/b304c13f810f9d52e32fbf6c778af3d9 to your computer and use it in GitHub Desktop.
Save cessationoftime/b304c13f810f9d52e32fbf6c778af3d9 to your computer and use it in GitHub Desktop.
Use different assets for different configurations with Play Framework
...
assets.path="/public"
...
package controllers
import play.api.Play
import play.api.mvc.Action
import play.api.mvc.AnyContent
import com.google.inject.Inject
import play.api.http.HttpErrorHandler
class ConfigurableAssets @Inject() (playConfig: play.api.Configuration, errorHandler: HttpErrorHandler) extends AssetsBuilder(errorHandler) {
private val assetsPath = playConfig.getString("assets.path").getOrElse("/public")
def at(file:String): Action[AnyContent] = {
at(assetsPath, file)
}
def versioned(file:String): Action[AnyContent] = {
versioned(assetsPath, file)
}
}
...
assets.path="/dist"
...
#static files
GET /assets/*file controllers.ConfigurableAssets.versioned(file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment