grunt-filerev

WebJar for grunt-filerev

License

License

BSD
Categories

Categories

Github Development Tools Version Controls
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

github-com-yeoman-grunt-filerev
Last Version

Last Version

2.3.1
Release Date

Release Date

Type

Type

jar
Description

Description

grunt-filerev
WebJar for grunt-filerev
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/yeoman/grunt-filerev

Download github-com-yeoman-grunt-filerev

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/github-com-yeoman-grunt-filerev/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>github-com-yeoman-grunt-filerev</artifactId>
    <version>2.3.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/github-com-yeoman-grunt-filerev/
implementation 'org.webjars.npm:github-com-yeoman-grunt-filerev:2.3.1'
// https://jarcasting.com/artifacts/org.webjars.npm/github-com-yeoman-grunt-filerev/
implementation ("org.webjars.npm:github-com-yeoman-grunt-filerev:2.3.1")
'org.webjars.npm:github-com-yeoman-grunt-filerev:jar:2.3.1'
<dependency org="org.webjars.npm" name="github-com-yeoman-grunt-filerev" rev="2.3.1">
  <artifact name="github-com-yeoman-grunt-filerev" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='github-com-yeoman-grunt-filerev', version='2.3.1')
)
libraryDependencies += "org.webjars.npm" % "github-com-yeoman-grunt-filerev" % "2.3.1"
[org.webjars.npm/github-com-yeoman-grunt-filerev "2.3.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.webjars.npm : chalk jar [1.0.0,2)
org.webjars.npm : convert-source-map jar [1.0.0,2)
org.webjars.npm : each-async jar [0.1.3,0.2)

Project Modules

There are no modules declared in this project.

grunt-filerev Build Status

Static asset revisioning through file content hash

Getting Started

If you haven't used grunt before, be sure to check out the Getting Started guide, as it explains how to create a gruntfile as well as install and use grunt plugins. Once you're familiar with that process, install this plugin with this command:

$ npm install --save-dev grunt-filerev

Overview

This task will revision your files based on its contents. You should then set the files to expire far into the future for better caching and it will only update when it changes.

Example

grunt.initConfig({
  filerev: {
    options: {
      algorithm: 'md5',
      length: 8
    },
    images: {
      src: 'img/**/*.{jpg,jpeg,gif,png,webp}'
    }
  }
});

Options

algorithm

Type: string
Default: 'md5'

algorithm is dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are 'sha1', 'md5', 'sha256', 'sha512', etc. On recent releases, openssl list-message-digest-algorithms will display the available digest algorithms.

length

Type: number
Default: 8

Number of characters of the file hash to prefix the file name with.

process(basename, name, extension)

Type: function
Default: null
Returns: string

Function to process the revised file name and return back the new file name.

basename

Type: string

Basename of the file.

name

Type: string

Name with the revision suffixed.

extension

Type: string

The file extension.

Destination

It will overwrite the src files if you don't specify a dest:

filerev: {
  images: {
    src: ['img1.png', 'img2.png'],
    dest: 'tmp'
  }
}

Summary

The task keeps track of all files created and its sources in a summary that is exposed through the grunt.filerev.summary object. It can be used to replace references to the revved files or debugging purposes. The key of the object is the original filename, the value is the new revved path.

For a configuration like this

filerev: {
  images: {
    src: ['img1.png', 'img2.png'],
    dest: 'tmp'
  }
}

the content grunt.filerev.summary could look like that:

{
  'img1.png': 'tmp/img1.59bcc3ad.png',
  'img2.png': 'tmp/img2.060b1aa6.png'
}

Source Maps

The task will ensure that any source map for .css or .js file is revisioned with the same revision as the source file.

For example, js/main.js revisioned to js/main.9d713a59.js will also have js/main.js.map revisioned to the same hash js/main.9d713a59.js.map.

License

BSD license and copyright Google

org.webjars.npm

Yeoman

The web's scaffolding tool for modern webapps

Versions

Version
2.3.1
2.3.0