npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-userev

v0.0.6

Published

Update references to assets versioned with grunt-filerev. Leaner and faster than grunt-usemin, and able to update already versioned references.

Downloads

25

Readme

grunt-userev

Update references to assets versioned with grunt-filerev. Leaner and faster than grunt-usemin, and able to update already versioned references.

build npm version 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-userev --save-dev

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

grunt.loadNpmTasks('grunt-userev');

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 assets': /(css\/[a-z0-9.]*\.css)/,
        },
      },
    },
  },
});

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 patterns.

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.

Roadmap

  • Add changelog
  • Extend tests

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.

Submit a pull request

  • Fork the repository (help) and checkout new branch prefixed with either feature-, or fix-, or docs-, or chore-.
  • Use the popular JavaScript style convention and winning JavaScript style with exception of 100 characters per line. In short, use 2 spaces indent, camelCase names, trailing comma, single quotes, semicolons, sparse spacing, and no trailing whitespace.
  • For a bugfix, write a test that exposes the bug and fails before applying your fix. Submit the test alongside the fix.
  • For a new feature, add tests that cover the feature.
  • Lint and test your code by running grunt, or grunt watch to watch source files and run tests on any change.
  • Use commit messages suitable for generating changelog and following Karma/Angular commit message convention (docs). In short, use <type>(<scope>): <subject> header in imperative present tense, message body describing motivation/differences, and footer referencing related issues and breaking changes.
  • Create a pull request (help) to grunt-userev master branch.

License

Copyright 2013 Salsita Software. Licensed under the MIT License.