dwickern / sbt-web-brotli   1.1.0

GitHub

Sbt-web plugin for brotli-compression of web assets

Scala versions: 2.12
sbt plugins: 1.0

sbt-web-brotli

build Maven Central

sbt-web plugin for brotli-compressing web assets using jvmbrotli bindings.

Rewritten from sbt-gzip sources, thanks to Typesafe/Lightbend. Some parts of code, docs, tests are copy-pasted with no changes.

Usage

Add the plugin to project/plugins.sbt:

addSbtPlugin("com.github.dwickern" % "sbt-web-brotli" % "1.1.0")

Add brotli to the sbt-web asset pipeline in your build.sbt:

pipelineStages := Seq(brotli)

Pipeline stages are only used in the production build. To see the output of your pipeline, run in your sbt shell:

> show webStage

Configuration

Filters

Include and exclude filters can be provided. For example, to only create brotli files for .js files:

brotli / includeFilter := "*.js"

Or to exclude all .js files but include any other files:

brotli / excludeFilter := "*.js"

The default filters configured like this:

brotli / includeFilter := "*.html" || "*.css" || "*.js"
brotli / excludeFilter := HiddenFileFilter || "*.woff" || "*.woff2" || "*.gz"

Usage with sbt-gzip

If you also use sbt-gzip, make sure brotli comes after gzip in the pipeline:

pipelineStages := Seq(gzip, brotli)

Or, alternatively, configure gzip to ignore the brotli-compressed files:

pipelineStages := Seq(brotli, gzip)
gzip / excludeFilter ~= { _ || "*.br" }

License

This code is licensed under the Apache 2.0 License.