Skip to content

Sbt-web plugin for brotli-compression of web assets

Notifications You must be signed in to change notification settings

suggestio/sbt-web-brotli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sbt-web-brotli

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

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

Add plugin

Add the plugin to project/plugins.sbt. For example:

resolvers += (
  "bintray-nitram509-jbrotli" at "http://dl.bintray.com/nitram509/jbrotli"
)

// Brotli itself implemented in C, so you need native `.so/.dll` library in your classpath.
// All pre-built arch at https://dl.bintray.com/nitram509/jbrotli/org/meteogroup/jbrotli/
// UNCOMMENT one or more architectures, suitable for your needs:
libraryDependencies ++= Seq(
  //"org.meteogroup.jbrotli" % "jbrotli-native-darwin-x86-amd64" % "0.5.0"
  //"org.meteogroup.jbrotli" % "jbrotli-native-linux-arm32-vfp-hflt" % "0.5.0"
  //"org.meteogroup.jbrotli" % "jbrotli-native-linux-x86-amd64" % "0.5.0"
  //"org.meteogroup.jbrotli" % "jbrotli-native-win32-x86-amd64" % "0.5.0"
  //"org.meteogroup.jbrotli" % "jbrotli-native-win32-x86" % "0.5.0"
)

// PUBLIC REPO NOT READY YET, SORRY. RE-BUILD SOURCES BY HANDS
addSbtPlugin("io.suggest" % "sbt-web-brotli" % "0.5.6-SNAPSHOT")

Your project's build file also needs to enable sbt-web plugins. For example with build.sbt:

lazy val root = (project.in file(".")).enablePlugins(SbtWeb)

As with all sbt-web asset pipeline plugins you must declare their order of execution e.g.:

pipelineStages := Seq(brotli)

Configuration

Filters

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

includeFilter in brotli := "*.js"

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

excludeFilter in brotli := "*.js"

The '''default''' filters configured like this:

includeFilter in brotli := "*.html" || "*.css" || "*.js"

excludeFilter in brotli := HiddenFileFilter || "*.woff" || "*.woff2" || "*.gz"

If you also using sbt-gzip, you may want configure it to ignore brotli-compressed files:

excludeFilter in gzip := "*.woff" || "*.woff2" || "*.br"

License

This code is licensed under the Apache 2.0 License.

Releases

No releases published

Packages

No packages published

Languages