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

fly-rev

v2.3.0

Published

Append a unique hash to filename. Optionally create a manifest mapping. Optionally rewrite references to updated filenames.

Downloads

47

Readme

fly-rev Build status npm package

Prepare front-end assets for cache-busting / versioning / hashing.

This plugin includes three functions:

  1. rev(): Rename files by appending a unique hash, based on contents.
  2. revManifest(): Create a manifest that maps old filenames to newly versioned filenames. (optional)
  3. revReplace(): Update all references to versioned files. (optional)

Make sure to set the files to never expire for this to have an effect.

Install

npm install --save-dev fly-rev

Usage

The rev() task is the core method; thus is required for anything to occur.

Both revManifest() and revReplace() are optional plugins.

exports.default = function * (fly) {
  yield fly.source('app/**/*')
    .rev({
      ignores: ['.html', '.jpg', '.png']
     })
    .revManifest({
      dest: 'dist',
      file: 'manifest.json',
      trim: str => str.replace(/app\/client/i, 'assets')
    })
    .revReplace({
      ignores: ['.php']
    })
    .target('dist');
}

API

.rev(options)

Generate a unique hash (based on a file's contents) and append it to the filename.

bundle.js
//=> bundle-{hash}.js
bundle.min.js
//=> bundle-{hash}.min.js

Any files that are processed will receive two new keys: orig and hash. In addition, the base key will be updated with the new, versioned filename.

options.ignores

Type: array Default: ['.png', 'jpg', '.jpeg', '.svg', '.gif', '.woff', '.ttf', '.eot']

A list of file extensions that should NOT be renamed/processed.

revManifest(options)

Create a manifest file that relates old filenames to versioned counterparts.

options.file

Type: string Default: 'rev-manifest.json'

The name of the manifest file to be created.

options.dest

Type: string Default: fly.root

The directory where your manifest file should be created. Defaults to Fly's root directory (where flyfile.js is found).

options.sort

Type: boolean Default: true

Whether or not the manifest's contents should be sorted alphabetically. (Does not add any performance / usage benefits.)

options.trim

Type: string or function Default: .

Edit the final keys & values within the manifest. If string, the value will be resolved relative to Fly's root directory. Using a function provides more fine-tuned control.

yield fly.source('app/client/*.js').rev()
  .revManifest({trim: 'app'}).target('dist');
  //=> "client/demo.js": "client/demo-1abd624s.js"

yield fly.source('app/client/*.js').rev()
  .revManifest({
    trim: str => str.replace(/app\/client/i, 'assets')
  }).target('dist');
  //=> "assets/demo.js": "assets/demo-1abd624s.js"

revReplace(options)

Update references to all versioned files within a given source.

Matching files from within fly.source() are available for inspection & modifications. Because of this, it is recommended that all your rev-* usage is extracted to a separate, production-only task whose source includes all development files.

options.ignores

Type: array Default: ['.png', 'jpg', '.jpeg', '.svg', '.gif', '.woff', '.ttf', '.eot']

A list of file extensions whose content should not be updated.

License

MIT © Luke Edwards