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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vycital/rehash

v1.0.0

Published

A CLI tool for cache-busting static assets by embedding hashes in filenames and updating references

Readme

Rehash

A CLI tool for cache-busting static assets by embedding hashes in filenames and updating references.

Features

  • Renames files by embedding a hash in filename (e.g., file.jsfile.rehash--abc123...--rehash.js)
  • Updates references in HTML and JS files to point to the newly renamed files
  • Supports glob patterns for selecting files to rehash and update
  • Handles source maps (.map files) automatically
  • Multiple passes ensure all references are updated correctly

Installation

npm install -g rehash

Or use locally in your project:

npm install rehash --save-dev

Usage

rehash [options] [directory]

Arguments

  • directory - Directory to process (defaults to current working directory). All globs are resolved relative to this directory.

Options

| Option | Short | Description | Default | | ----------------- | ----- | ------------------------------------------------ | ------------------ | | --rehash <glob> | -r | Glob pattern for files to rehash | See defaults below | | --update <glob> | -u | Glob pattern for files to update with new hashes | See defaults below | | --ignore <glob> | -i | Glob pattern for files to ignore | None | | --help | -h | Show help message | N/A |

Default Behavior

If no --rehash nor --update options are provided, rehash uses sensible defaults:

Files to rehash:

**/*.css
**/*.eot
**/*.gif
**/*.ico
**/*.jpeg
**/*.jpg
**/*.js
**/*.json
**/*.png
**/*.svg
**/*.swf
**/*.ttf
**/*.wasm
**/*.webp
**/*.woff
**/*.woff2

Files to update:

**/*.html
**/*.js

Examples

Basic usage (current directory)

rehash

Process a specific directory

rehash dist/

Custom file patterns

# Only rehash JS and CSS files, don't update any files
rehash --rehash "**/*.js" --rehash "**/*.css"

# Rehash all assets and update HTML files
rehash --rehash "**/*.{js,css,png,jpg}" --update "**/*.html"

# Ignore certain files from rehashing and from updating
rehash --ignore "submodule/**"

Multiple patterns

rehash \
  --rehash "**/*.js" \
  --rehash "**/*.css" \
  --update "**/*.html" \
  --update "**/index.js" \
  --ignore "**/node_modules/**"

How It Works

  1. Rehash Phase: Files matching the rehash glob patterns are renamed with a hash embedded in the filename (format: filename.rehash--[hash]--rehash.extension)
  2. Update Phase: Files matching the update glob patterns have their content scanned for references to the original filenames, which are replaced with the new hashed filenames
  3. Multiple Passes: The tool runs multiple passes until no more changes are detected, ensuring all references are properly updated

File Naming Format

When a file is rehashed, it follows this naming convention:

original-name.rehash--[sha256-hash]--rehash.extension

For example:

script.js → script.rehash--a1b2c3d4e5f6...--rehash.js
image.png → image.rehash--f7e8d9c0b1a2...--rehash.png

Supported Reference Formats

The tool updates references in the following formats:

  • Double quotes: "file.js"
  • Single quotes: 'file.js'
  • Backticks: `file.js`
  • Relative paths with or without ./ prefix

FAQ

Rehash fails on my big complex project with many dependencies

Rehash is designed for simple static sites. It may not handle highly complex projects. You're welcome to open a PR if the fix is simple and doesn't introduce significant complexity, but such cases are generally out of scope for this tool.

I have dependency cycles in my project

Rehash will happily follow your dependency cycles indefinitely.

Can I use rehash with build tools like Webpack or Vite?

Please don't. These tools have their own asset handling and cache-busting mechanisms.

License

GNU Affero General Public License v3.0 - see LICENSE for details.