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-uncache

v0.4.0-beta1

Published

Append unique string or md5 hash to paths in html files to force refresh - remove users cache app.js -> app_8j3d7a4f.js

Downloads

1,089

Readme

gulp-uncache

NPM version Build Status Dependency Status Coverage Status Downloads

Append unique string or md5 hash to paths in html files to force refresh - remove users cache app.js -> app_8j3d7a4f.js

Supported script and link tags with src or href attributes.

Install

$ npm install --save-dev gulp-uncache

##Effect

Before:
<!-- uncache -->
<script src="app.js"></script>
<!-- enduncache -->

<!-- uncache(rename:true, append:hash, srcDir:src, distDir:dist) -->
<link rel="stylesheet" href="style.css"/>
<!-- enduncache -->

After:
<script src="app.js?1401482624657"></script>

<link rel="stylesheet" href="style_46fa2c8d60.css"/>

##Options

###append

Type String

default: time

String to append or one from:

time - append actual time stamp

hash - append md5 hash of file (prevent unnecessary refreshing file) need correct srcDir & distDir

###rename

Type Boolean

default: false

If set to true rename file otherwise append string as url query string

###srcDir

Type String

default: ./

Path to dir with source files. (Used only when rename:true, or append:'hash')

###distDir

Type String

default: ./

Path to dir where renamed files will be saved. (Used only when rename:true)

###template

Type String

default {{path}}{{name}}_{{append}}.{{extension}}

Template for replace (Hogan.js). Available variables: path, name, append, extension

###srcFileMap

Type Function

Parameters: fileName

Function for transforming src file path At default returns path.join(config.srcDir, fileName);

##Inline options You can set options inline that way: (omit quotes sign)

<!-- uncache(param:value, param:value) -->

Examples

Basic

#####gulpfile.js

var gulp = require('gulp');
var uncache = require('gulp-uncache');

gulp.task('default', function () {
    return gulp.src('src/index.html')
		.pipe(uncache({
            append: 'hash',
            rename: true,
            srcDir: 'src',
            distDir: 'dist'
		}))
		.pipe(gulp.dest('dist'));
});

#####src/index.html

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <!--uncache-->
    <link rel="stylesheet" href="style.css"/>
    <!--enduncache-->
</head>
<body>
    <!--uncache(rename:false)-->
    <script src="js/file.js"></script>
    <!--enduncache-->
</body>
</html>

#####dist/index.html

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="style_46fa2c8d60.css"/>
</head>
<body>
    <script src="js/file.js?46fa2c8d60"></script>
</body>
</html>

With other plugins

#####gulpfile.js

var gulp = require('gulp');
var usemin = require('gulp-usemin');
var uncache = require('gulp-uncache');

gulp.task('default', function () {
    return gulp.src('src/index.html')
        .pipe(usemin({
            js: []
        }))
        .pipe(uncache())
        .pipe(gulp.dest('dist'));
});

#####src/index.html

<!--uncache-->
<!-- build:js lib.js -->
<script src="js/file1.js"></script>
<script src="js/file2.js"></script>
<script src="js/file3.js"></script>
<!-- endbuild -->
<!--enduncache-->

#####dist/index.html

<script src="lib.js?1401393153336"></script>

To do

  • 'uncache' for all sources in files without <!--uncache--> tags
  • support css images (e.g. for often changing css sprites image)

Changelog

#####0.4.0-beta1

#####0.2.3

  • option template

#####0.2.2

  • inline options
  • fixed parsing regexp

#####0.2.0

  • option rename
  • option append hash
  • allow both ' and " in tags

#####0.1.3

  • added append option

#####0.1.2

  • fixed multi line blocks
  • fixed parsing lines with attributes
  • skipping incorrect tags
  • log info and errors

#####0.1.1

  • initial release

License

MIT © Maciej Dudziński