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

grunt-update-reference

v1.0.0

Published

A grunt plugin for fontend to bust cache via update file reference's hash parameter.

Downloads

10

Readme

grunt-update-reference

Grunt task for updating the changed resources's reference, to get cache bust.

Feature

It can also instantly update reference of one file which its content not changed by us, but changed by this task.

Task will print colored change log in console, for checking what modify the task has done.

It will only match the file name.

Getting Started

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a gruntfile.js as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-update-reference --save-dev

Once the plugin has been installed, it may be enabled inside your gruntfile.js with this line:

grunt.loadNpmTasks('grunt-update-reference');

Then, add and configure it to your Gruntfile.js:

grunt.initConfig({
    reference: {
        options:{
            //Define what files contain some reference.
            searchFileType: [ "*.html", "*.js", "*.css" ],
            //If has some file or path to ignore, path is base on "options.searchPathBase".
            searchIgnore:[ "ignore_me.html","ignore_me/**/*" ],
            //Task's log, "simple", "all" or "none"
            log:"simple"
        },
        dist: {
            options: {
                //The base path.
                searchPathBase: "./path_to",
                //Prevent watch instantly changes, which changed by this task.
                referenceIgnore:["*.html"]
            },
            //What kind of files that may needed to be update references.(path is not base on "options.searchPathBase")
            src: [ "path_to/**/*.{css,js,jpg,png,gif}" ]
        }
    }
  });

Run the grunt reference task:

If set log to "simple", the log will be like this:

$ grunt reference

Running "reference:dist" (reference) task
Running "newer:reference_core:dist__path_to" (newer) task
Running "reference_core:dist__path_to" (reference_core) task

Assets: foo.jpg
refresh foo.jpg's reference in bar.css
refresh bar.css's reference in index.html

Done, without errors.

If set log to "all":

$ grunt reference

Running "reference:dist" (reference) task
Running "newer:reference_core:dist__path_to" (newer) task
Running "reference_core:dist__path_to" (reference_core) task

Assets: foo.jpg
Scan changed files' reference in ./path_to
in file bar.css replace:
    background:url("./foo.jpg");
--->
    background:url("./foo.jpg?h=98e8485471");
File bar.css instantly changed, rescan path.
+       Scan changed files' reference in ./path_to
+       in file index.html replace:
+       <link href="./bar.css?v=2" rel="stylesheet" type="text/css" />
+       --->
+       <link href="./bar.css?h=98e8485471&v=2" rel="stylesheet" type="text/css" />

Done, without errors.