1.2.0 • Published 5 years ago

gulp-tpl-rev v1.2.0

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

gulp-tpl-rev Build Status

Static asset revisioning by appending content hash to filenames unicorn.cssunicorn.css?_v=995025`

Install

$ npm install --save-dev gulp-tpl-rev

Usage

const gulp = require('gulp');
const tpl = require('gulp-tpl-rev');
const crypto = require('crypto');
const path = require('path');
const fs= require('fs')

exports.default = () => (
	gulp.src('src/*.html')
		.pipe(tpl( function(pathname) {
				const { ext } = path.parse(pathname)
				const fullpath = path.join(__dirname, 'wwwroot', pathname)
				if (fs.existsSync(fullpath)) {
					const file = fs.readFileSync(fullpath, 'utf8')
					const md5 = crypto.createHash('md5');
					md5.update(file);
					return md5.digest('hex').slice(0, 6)
				}
				return ""
			}
		))
		.pipe(gulp.dest('dist'))
);
1.2.0

5 years ago

1.1.0

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago