gulp-bustcache

1.0.0 • Public • Published

gulp-bustcache

bustcache is a tool for cache busting with gulp without the need for query strings. The plugin adds a random hash to the filename just before the extension.

INSTALL

With npm do:

npm install gulp-bustcache

USAGE

var gulp = require('gulp'),
    bust = require('gulp-bustcache');
    
gulp.task('bust', function() {
	gulp.src(['./src/**/*'])
		.pipe(bust())
		.pipe(gulp.dest('./public'));
});

The above code will run through every file in the 'src' folder and move it to 'public' with a hash in it's name. For example a file named :

src/main.js 

Will be something like

public/main.7d6aa59b7be25c3eed016106500d08ca.js

To replace the names inside your html files you can use the gulp-replace plugin and do something like

gulp.task('js-replace', function() {
	gulp.src(['./*.html']).pipe(replace(/\/main.*js/g, '/main.7d6aa59b7be25c3eed016106500d08ca.js')).pipe(gulp.dest('./'));
});

The above code assumes a single file name (for the sake of the example) and changes a specific pattern for JS files.

please be aware that this is not the best solution, just an idea.

LICENSE

MIT

Package Sidebar

Install

npm i gulp-bustcache

Weekly Downloads

3

Version

1.0.0

License

MIT

Last publish

Collaborators

  • marcallkz