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

gulp-bust

v0.2.2

Published

Gulp cache busting with development or production mappings

Downloads

14

Readme

gulp-bust NPM version Build status

Gulp cache busting with development or production mappings

Installation

npm install gulp-bust

Usage

var gulp = require('gulp'),
    Bust = require('gulp-bust');

var bust = new Bust();

gulp.task('assets', function () {
  return gulp.src(['src/img/*.png', 'src/css/*.css', 'src/js/*.js'])
    .pipe(bust.resources())
    .pipe(gulp.dest('dist/public'));
});

gulp.task('templates', function () {
  return gulp.src('src/templates/*')
    .pipe(bust.references())
    .pipe(gulp.dest('views'));
});

Initialisation

var bust = new Bust([options]);

Options can be set on initialisation or at a later point by dirrectly updating the settings hash.

bust.settings.production = false;

Options

hashLength (number)

default: false

Numerical value if you wish to shorten your checksum length. e.g.

new Bust({ hashLength: 12 });

Will cut checksum hashes down to 12 characters.

hashType (string)

default 'md5'

Any Node crypto hash type. e.g.

new Bust({ hashType: 'sha1' });

production (boolean)

default true

Boolean flag to set/unset production mode.

When set to false Bust will not add checksum hashes to files but will generate a mappings object.

Resources

bust.resources()

Renames and maps to resources as they pass through. Checksums are generated against file contents so will only change if the file contents change. So a file such as: foo.png might become: foo.3858f62230ac3c915f300c664312c63f.png. All file references will also be recorded on the mappings object.

References

bust.references()

Updates file content such as your templates to refer to files previously renamed by bust.resources(). A template such as:

html
  head
    link(href='/public/css/style.css', rel='stylesheet')
  body

might become:

html
  head
    link(href='/public/css/style.3858f62230ac3c915f300c664312c63f.css', rel='stylesheet')
  body

The mappings object

The mappings object can be accessed via bust.mappings and can be useful for referring to dynamically rendered content within templates.

By default when the production flag in settings is set to true the mappings object will look something like:

{
  "foo.png": "foo.3858f62230ac3c915f300c664312c63f.png",
  "bar.css": "bar.6754fsd205aasd944d523sd4so40i98d.css"
}

If the production flag is set to false the mappings object will look something like:

{
  "foo.png": "foo.png",
  "bar.css": "bar.css"
}

Licence

MIT