Play Framework and sbt-web plugin for brotli-compressing web assets at build-time using brotli4j bindings.
Rewritten from sbt-gzip sources, thanks to Typesafe/Lightbend. Some parts of code, docs, tests are copy-pasted with no changes.
Add the plugin to project/plugins.sbt
:
addSbtPlugin("com.github.dwickern" % "sbt-web-brotli" % "2.0.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:
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"
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" }
If you encounter java.lang.UnsatisfiedLinkError: Failed to load Brotli native library
useCoursier
setting)Otherwise, you can add the brotli4j native library for your platform to libraryDependencies
in project/plugins.sbt
.
This code is licensed under the Apache 2.0 License.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4