gulp-filename-hash

0.2.1 • Public • Published

Replace filenames with a md5 string, or append filenames with a md5 string as query parameter.

For example:

var dest = '../dist';
var hash = require('gulp-add-hash');

gulp.task('html', ['less', 'js'], function(){
  gulp.src(['**/*.src.jade'])
      .pipe(data(function() {
        return require('./data');
      }))
      .pipe(jade({pretty: false}))
      .pipe(hash({  
        query: true,
        base: dest
      }))
      .pipe(gulp.dest(dest))
});

Options:

  • query -- default: false

    • false, <link href="index.css"> ===> <link href="index_fdafda6789.css">, the filename of index.css will be changed.
    • true, <link href="index.css"> ===> <link href="index.css?v=fdafda6789">
  • base -- base dir, default: ./

  • length -- the length of md5 string, default: 10

  • ext -- allowed extensions, type: Array, default: ['.css', '.js', '.jpg', '.png', '.gif']

Note:

  • Before using the gulp-filename-hash, You must make sure that all the static files have been generated.(See Synchronous tasks with Gulp), otherwize the gulp-filename-hash will skip.
  • This gulp plugin only checks the link in href, src and url(), and then appends a md5 string to them.

Readme

Keywords

Package Sidebar

Install

npm i gulp-filename-hash

Weekly Downloads

6

Version

0.2.1

License

MIT

Last publish

Collaborators

  • flfwzgl