Skip to content
/ sbt-digest Public

sbt-web plugin for checksum files

Notifications You must be signed in to change notification settings

sbt/sbt-digest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sbt-digest

sbt-web plugin for adding checksum files for web assets. Checksums are useful for asset fingerprinting and etag values.

Build Status

The plugin works by prepending a digest to the asset name. The default digest algorithm used is MD5. In addition an .md5 file (depending on the algorithm) is also generated containing the hash. The hash can then be used to lookup the associated hashed file.

You may have an asset such as:

./target/web/public/test/public/images/example.png

sbt-digest will create a second copy of the file with the hash and a digest file:

./target/web/digest/images/23dcc403b263f262692ac58437104acf-example.png
./target/web/digest/images/example.png.md5

Add plugin

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

addSbtPlugin("com.github.sbt" % "sbt-digest" % "2.0.0")

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(digest)

Configuration

Algorithms

Supported hash algorithms are md5 and sha1. The default is to only create md5 checksum files. To configure this, modify the algorithms setting. For example, to also generatesha1 checksum files:

DigestKeys.algorithms += "sha1"

Filters

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

digest / includeFilter := "*.js"

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

digest / excludeFilter := "*.js"

Contribution policy

Contributions via GitHub pull requests are gladly accepted from their original author.

License

This code is licensed under the Apache 2.0 License.