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

webpack-uri-search-hash

v1.0.1

Published

Webpack plugin that appends content hashes to asset URLs via query strings.

Readme

webpack-uri-search-hash

A webpack 5 plugin that keeps emitted asset filenames stable on disk, but appends a content-derived query hash to the asset URLs webpack generates.

What it does

Instead of changing filenames like this:

  • main.abc123.js
  • lazy.def456.css

this plugin keeps the files themselves stable:

  • main.js
  • lazy.css

but rewrites the generated request URLs to include a hash in the query string:

  • main.js?hash=abc123...
  • lazy.css?hash=def456...

That gives you cache busting through the URL while preserving stable on-disk filenames.

What it supports

  • webpack 5
  • async JavaScript chunk loading
  • async CSS chunk loading via mini-css-extract-plugin
  • entry <script> and <link> tags generated by html-webpack-plugin

What it does not do

  • it does not rename emitted files
  • it does not rewrite hand-written HTML files
  • it does not support webpack 4

Installation

npm install -D webpack-uri-search-hash

You will typically also use it with webpack 5, and optionally:

  • html-webpack-plugin
  • mini-css-extract-plugin

Usage

Basic usage

const UriSearchHashPlugin = require('webpack-uri-search-hash');

module.exports = {
  output: {
    filename: 'main.js',
    chunkFilename: '[name].js',
  },
  plugins: [new UriSearchHashPlugin()],
};

With that setup, webpack can still emit files like:

  • main.js
  • lazy.js

but runtime chunk requests become:

  • lazy.js?hash=<contenthash>

With CSS chunks

const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UriSearchHashPlugin = require('webpack-uri-search-hash');

module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: [MiniCssExtractPlugin.loader, 'css-loader'],
      },
    ],
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: 'main.css',
      chunkFilename: '[name].css',
    }),
    new UriSearchHashPlugin(),
  ],
};

Async CSS requests then become:

  • lazy.css?hash=<contenthash>

With HtmlWebpackPlugin

const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UriSearchHashPlugin = require('webpack-uri-search-hash');

module.exports = {
  plugins: [
    new MiniCssExtractPlugin({ filename: 'main.css' }),
    new HtmlWebpackPlugin(),
    new UriSearchHashPlugin(),
  ],
};

Generated tags become:

<script defer="defer" src="main.js?hash=<contenthash>"></script>
<link href="main.css?hash=<contenthash>" rel="stylesheet">

Options

queryKey

Type: string Default: 'hash'

Controls the query parameter name.

new UriSearchHashPlugin({
  queryKey: 'v',
});

Result:

  • lazy.js?v=<contenthash>

hashFormat

Type: string Default: '[contenthash]'

Controls how the hash value is rendered in the query string.

Supported forms follow webpack-style content hash placeholders:

  • [contenthash]
  • [contenthash:8]
  • custom wrappers like v-[contenthash:8]
new UriSearchHashPlugin({
  hashFormat: 'v-[contenthash:8]',
});

Result:

  • lazy.js?hash=v-1a2b3c4d

You can combine both options:

new UriSearchHashPlugin({
  queryKey: 'version',
  hashFormat: 'build-[contenthash:12]',
});

Result:

  • lazy.js?version=build-1a2b3c4d5e6f

License

MIT