• This repository has been archived on 26/Mar/2018
  • Stars
    star
    260
  • Rank 157,189 (Top 4 %)
  • Language
    JavaScript
  • Created over 11 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[DEPRECATED] File revving

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

More Repositories

1

yeoman

Yeoman - a set of tools for automating development workflow
10,081
star
2

generator-angular

Yeoman generator for AngularJS
JavaScript
5,729
star
3

yo

CLI tool for running Yeoman generators
JavaScript
3,835
star
4

generator-webapp

A gulp.js generator for modern webapps
JavaScript
3,770
star
5

generator-chrome-extension

Scaffold out a Chrome extension
JavaScript
2,617
star
6

update-notifier

Update notifications for your CLI app
JavaScript
1,762
star
7

generator-generator

Generate a Yeoman generator
JavaScript
1,223
star
8

grunt-usemin

[UNMAINTAINED] Replaces references to non-optimized scripts or stylesheets into a set of HTML files (or any templates/views)
JavaScript
1,219
star
9

generator

Rails-inspired generator system that provides scaffolding for your apps
TypeScript
1,204
star
10

yeoman-app

A desktop app that scaffolds projects using Yeoman
JavaScript
988
star
11

generator-webapp_DEPRECATED

Yeoman generator that scaffolds out a front-end web app
JavaScript
974
star
12

generator-polymer

Scaffold out a Polymer project
JavaScript
926
star
13

generator-mobile

Scaffold out a mobile project based on Web Starter Kit
JavaScript
918
star
14

configstore

Easily load and persist config without having to think about where and how
JavaScript
866
star
15

yeoman.io

Yeoman website
CSS
790
star
16

generator-backbone

Scaffold out a Backbone.js project
JavaScript
638
star
17

generator-node

Create a Node.js module
JavaScript
577
star
18

insight

Node.js module to help you understand how your tool is being used by anonymously reporting usage metrics to Google Analytics
JavaScript
557
star
19

bower-requirejs

[DEPRECATED] Automagically wire-up installed Bower components into your RequireJS config
JavaScript
375
star
20

generator-chromeapp

Scaffold out a Chrome app
JavaScript
310
star
21

stringify-object

Stringify an object/array like JSON.stringify just without all the double-quotes
JavaScript
307
star
22

yosay

Tell Yeoman what to say
JavaScript
206
star
23

grunt-bower-requirejs

[DEPRECATED] Grunt task - Automagically wire-up installed Bower components into your RequireJS config
JavaScript
198
star
24

generator-bootstrap

Yeoman generator for Bootstrap
JavaScript
186
star
25

generator-karma

Yeoman generator for Karma
JavaScript
172
star
26

environment

Yeoman runtime environment
JavaScript
127
star
27

generator-jquery

Generate a jQuery plugin
JavaScript
85
star
28

generator-gruntfile

Create a basic Gruntfile with yo.
JavaScript
74
star
29

doctor

Detect potential issues with users system that could prevent Yeoman from working correctly
JavaScript
61
star
30

yeoman-assert

Assert utility from yeoman
JavaScript
53
star
31

yeoman-generator-list

JavaScript
52
star
32

yeoman-test

Test utilities for Yeoman generators
TypeScript
44
star
33

generator-mocha

Yeoman generator for Mocha
JavaScript
41
star
34

generator-gruntplugin

Create a gruntplugin module with yo, including Nodeunit unit tests.
JavaScript
35
star
35

generator-jasmine

Yeoman generator for Jasmine
JavaScript
34
star
36

yeoman-character

The Yeoman character in your CLI. Like wat.
JavaScript
21
star
37

yeoman-welcome

Yeoman welcome message used in generators
JavaScript
19
star
38

media

Yeoman logo and artwork
16
star
39

generator-commonjs

Generate a CommonJS module
JavaScript
16
star
40

insight-dashboard

[DEPRECATED] Insight into Yeoman
CSS
11
star
41

Hackathons

Running a Yeoman hackathon? Start here for ideas, tips, and goals
10
star
42

html-wiring

[DEPRECATED] Set of utilities to update HTML files
JavaScript
10
star
43

cli-list

Parse comma-separated argument lists.
JavaScript
9
star
44

yeoman-remote

Fetch packages and archives from remote resources with cache support
JavaScript
8
star
45

generator-dummytest

JavaScript
3
star
46

generator-dummy

Dummy generator used for unit testing purpose
JavaScript
2
star
47

yeoman-api

TypeScript
1
star