Skip to content

dwickern/sbt-web-brotli

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sbt-web-brotli

build Maven Central

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.

Usage

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:

> 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" }

Troubleshooting

If you encounter java.lang.UnsatisfiedLinkError: Failed to load Brotli native library

  1. Upgrade to sbt 1.7.3 or later, which includes an important fix coursier#2286
  2. Make sure you're using a platform supported by brotli4j
  3. Make sure Couriser is not disabled (e.g. with the useCoursier setting)

Otherwise, you can add the brotli4j native library for your platform to libraryDependencies in project/plugins.sbt.

License

This code is licensed under the Apache 2.0 License.

About

Sbt-web plugin for brotli-compression of web assets

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Scala 100.0%