-
-
Save cessationoftime/b304c13f810f9d52e32fbf6c778af3d9 to your computer and use it in GitHub Desktop.
Use different assets for different configurations with Play Framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
assets.path="/public" | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
assets.path="/dist" | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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