This package has been deprecated

Author message:

UNMAINTAINED

grunt-userev2

0.1.5 • Public • Published

grunt-userev2

Update references to assets versioned with grunt-filerev.

npm  Build Status dependencies dev-dependencies

Getting Started

This plugin requires Grunt.

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, you may install this plugin with this command:

npm install grunt-userev2 --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-userev2');

The "userev" task

Overview

In your project's Gruntfile, configure userev to update references to assets versioned by grunt-filerev. It will automatically use grunt.filerev.summary.

grunt.initConfig({
  filerev: {
    options: {
      encoding: 'utf8',
      algorithm: 'md5',
      length: 8
    },
    sourcemaps: {        // Rename sourcemaps.
      src: ['build/css/*.map.css', 'build/js/*.map.js'],
    },
    assets: {            // Rename minified js/css.
      src: ['build/css/*.css', 'build/js/*.js', '!build/css/*.map.css', '!build/js/*.map.js'],
    },
  },

  userev: {
    options: {
      hash: /(\.[a-f0-9]{8})\.[a-z]+$/,
    },
    assets: {            // Link to sourcemaps in minified js/css.
      src: ['build/css/*.css', 'build/js/*.js', '!build/css/*.map.css', '!build/js/*.map.js'],
      options: {
        patterns: {
          'Linking versioned source maps': /sourceMappingURL=([a-z0-9.]*\.map)/,
        },
      },
    },
    index: {             // Link to minified js/css in index html.
      src: 'build/index.html',
      options: {
        patterns: {
          'Linking versioned asset': /(css\/[a-z0-9./]*\.css)/,
          'Linking versioned assets': /(css\/[a-z0-9./]*\.css)/g,
        },
      },
    },
  },
});

grunt.registerTask( 'rev', [
  'filerev:sourcemaps',  // Rename sourcemaps.
  'userev:assets',       // Link to sourcemaps in minified js/css.
  'filerev:assets',      // Rename minified js/css.
  'userev:index',        // Link to minified js/css in index html.
]);

Options

patterns

Type: Object {Key: RegExp} Default: none

Reference RegExp patterns are matched in source files. The first matched group is checked if it matches ending of any key in grunt.filerev.summary. The key names are used to log processing of matched pattern.

To match multiple assets in a single file set the global modifier.

hash

Type: RegExp Default: none

If specified, the RegExp pattern is matched against matched references and the first matched group (the hash in filename) is removed. This allows to update the references in source files multiple times without need to regenerate them.

Contributing

Welcome to the project. Choose a way that suits you. You'll need a GitHub account.

Submit a bug, or feature request

  • Search existing issues to avoid duplicities.
  • Submit an issue with label bug, or enhancement.
  • For a bug, include any relevant information, e.g. task output, installed OS/Node.js/Grunt/grunt-userev versions, and steps to reproduce.

License

Copyright 2013 Salsita Software. Licensed under the MIT License.

Package Sidebar

Install

npm i grunt-userev2

Weekly Downloads

27

Version

0.1.5

License

none

Last publish

Collaborators

  • k3karthic