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

mix-gulp-hash-src

v0.1.6

Published

Automatically add cache busting hashes to links in HTML and CSS,inherit form [gulp-hash-src](https://www.npmjs.com/package/gulp-hash-src)

Downloads

4

Readme

mix-gulp-hash-src

Automatically add cache busting hashes to links in HTML and CSS, copyright mix corp. inherit form gulp-hash-src

Usage

var gulp = require("gulp"),
    hash_src = require("gulp-hash-src");

gulp.task("hash", function() {
    return gulp.src(["./client/**/*.html", "./client/**/*.css"])
        .pipe(hash_src({build_dir: "./build", src_path: "./client"}))
        .pipe(gulp.dest("./build"))
});

Or added it to the pipe line:

var gulp = require("gulp"),
    htmlmin = require("gulp-htmlmin"),
    hash_src = require("gulp-hash-src");

gulp.task("html", ["js", "css"], function ()
{
    return gulp.src("./client/**/*.html")
        .pipe(htmlmin())
        .pipe(hash_src({build_dir: "./build", src_path: "./client"}))
        .pipe(gulp.dest("./build"))
});

That will turn something like

<script src="file.js">

into

<script src="file.js?cbh=0123456789abcdef">

or

html {
    background: url(image.jpg);
}

into

html {
    background: url(image.jpg?cbh=0123456789abcdef);
}

Note

The files that are to be hash must be located in build_dir prior to running hash_src().

Options

build_dir   Where the files are that need to be hashed (required)

src_path    Where the files originated from (required)

hash        The type of hash (default: "md5")

hash_len    The length of the hash (default: null)
            If hash_len is falsey, the entire hash is used.

enc         Hash encoding (default: "hex")

exts        An array of the types of files to hash
            (default: [".js", ".css", ".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".pdf", ".ico", ".ttf", ".woff", ".mp3", ".ogg", ".ogv", ".mp4", ".webm", ".zip", ".tar", ".gz", ".bz2"])

regex       The regular expression to find links
            (by default it looks for something like src="..." href="..." url(...)

analyze     The function to use to analyze the regular expression matches
            The function will receive an array of the matches from the regex.
            Must return an object like so:
            {
                prefix: "href=",
                link:   "/file.js",
                suffix: "",
                abs: false (optional)
            }

query_name  The query string to add to the hash (default: "cbh")
            Turns links into href="file.css?cbh=0123456789abcdef"
            To remove the string entirely, give a blank string and get
            href="file.css?0123456789abcdef"

verbose     Whether or not to log info about what is happening (default: false)
            Useful for debugging

cdn_prefix  And cdn prefix url

cdn_prefix_except_ext  An array of the types of files no need to add cdn_prefix, example: ['.css']

License

MIT