sbt plugin that makes it less convoluted to use sbt-web and http4s together. It makes it such that assets are placed in paths that http4s is able to locate out of the box during development and production.
The plugin does this by tweaking a project's Runtime / managedClasspath
, Runtime / internalDependencyClasspath
, Assets / packagePrefix
and Compile / packageBin / mappings
.
Add the following to your project's project/plugins.sbt:
// replace x.y.z with value from version badge above.
addSbtPlugin("com.github.ahjohannessen" % "sbt-http4s-web" % "x.y.z")
and enable the plugin in your project's build:
.enablePlugins(Http4sWebPlugin)
The settings below are available for configuration. The following lists available setting keys and their default values:
import sbt._
import sbt.Keys._
import com.github.ahjohannessen.h4w.Http4sWebKeys._
/*
* Directory assets are placed during development.
* */
http4sWebAssetsDevTarget := target.value / "h4w"
/*
* Top-level directory under assets and that is used as package prefix.
* */
http4sWebAssetsBaseDirName := "public"
/*
* Exclude webjar assets under 'META-INF/resources/webjars/' when packaging project jar.
* */
http4sWebExcludeWebJarMappings := true
/*
* Prevent `packageBin in Assets` from being evaluated and added to `managedClasspath in Runtime`.
*
* It might be useful to prevent this in an IDE context that depends on evaluating
* `managedClasspath in Runtime` in order to build a project model from an sbt build.
*
* Default setting is to prevent evaluating `Assets / packageBin` when detecting
* Intellij IDEA has started the sbt instance.
* */
http4sWebPackageAssets := sys.props.get("idea.managed").isEmpty
sbt-revolver works great in conjunction with this plugin for fast development turnaround.
sbt-http4s-web
is licensed under APL 2.0