Gathering detailed insights and metrics for mix-gulp-hash-src
Gathering detailed insights and metrics for mix-gulp-hash-src
Gathering detailed insights and metrics for mix-gulp-hash-src
Gathering detailed insights and metrics for mix-gulp-hash-src
npm install mix-gulp-hash-src
Typescript
Module System
Node Version
NPM Version
69.6
Supply Chain
97.7
Quality
75.4
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
3,582
Last Day
1
Last Week
19
Last Month
31
Last Year
304
6 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Aug 18, 2016
Latest Version
0.1.6
Package Id
mix-gulp-hash-src@0.1.6
Size
3.49 kB
NPM Version
3.10.7
Node Version
6.6.0
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
0%
19
Compared to previous week
Last Month
933.3%
31
Compared to previous month
Last Year
-4.7%
304
Compared to previous year
Automatically add cache busting hashes to links in HTML and CSS, copyright mix corp. inherit form gulp-hash-src
1var gulp = require("gulp"), 2 hash_src = require("gulp-hash-src"); 3 4gulp.task("hash", function() { 5 return gulp.src(["./client/**/*.html", "./client/**/*.css"]) 6 .pipe(hash_src({build_dir: "./build", src_path: "./client"})) 7 .pipe(gulp.dest("./build")) 8});
Or added it to the pipe line:
1var gulp = require("gulp"), 2 htmlmin = require("gulp-htmlmin"), 3 hash_src = require("gulp-hash-src"); 4 5gulp.task("html", ["js", "css"], function () 6{ 7 return gulp.src("./client/**/*.html") 8 .pipe(htmlmin()) 9 .pipe(hash_src({build_dir: "./build", src_path: "./client"})) 10 .pipe(gulp.dest("./build")) 11});
That will turn something like
1<script src="file.js">
into
1<script src="file.js?cbh=0123456789abcdef">
or
1html { 2 background: url(image.jpg); 3}
into
1html { 2 background: url(image.jpg?cbh=0123456789abcdef); 3}
The files that are to be hash must be located in build_dir
prior to running hash_src()
.
build_dir Where the files are that need to be hashed (required)
src_path Where the files originated from (required)
hash The type of hash (default: "md5")
hash_len The length of the hash (default: null)
If hash_len is falsey, the entire hash is used.
enc Hash encoding (default: "hex")
exts An array of the types of files to hash
(default: [".js", ".css", ".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".pdf", ".ico", ".ttf", ".woff", ".mp3", ".ogg", ".ogv", ".mp4", ".webm", ".zip", ".tar", ".gz", ".bz2"])
regex The regular expression to find links
(by default it looks for something like src="..." href="..." url(...)
analyze The function to use to analyze the regular expression matches
The function will receive an array of the matches from the regex.
Must return an object like so:
{
prefix: "href=",
link: "/file.js",
suffix: "",
abs: false (optional)
}
query_name The query string to add to the hash (default: "cbh")
Turns links into href="file.css?cbh=0123456789abcdef"
To remove the string entirely, give a blank string and get
href="file.css?0123456789abcdef"
verbose Whether or not to log info about what is happening (default: false)
Useful for debugging
cdn_prefix And cdn prefix url
cdn_prefix_except_ext An array of the types of files no need to add cdn_prefix, example: ['.css']
No vulnerabilities found.