![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
gulp-hash-src
Advanced tools
Automatically add cache busting hashes to links in HTML and CSS.
var gulp = require("gulp"),
hash_src = require("gulp-hash-src");
gulp.task("hash", function() {
return gulp.src(["./client/**/*.html", "./client/**/*.css"])
.pipe(hash_src({build_dir: "./build", src_path: "./client"}))
.pipe(gulp.dest("./build"))
});
Or added it to the pipe line:
var gulp = require("gulp"),
htmlmin = require("gulp-htmlmin"),
hash_src = require("gulp-hash-src");
gulp.task("html", ["js", "css"], function ()
{
return gulp.src("./client/**/*.html")
.pipe(htmlmin())
.pipe(hash_src({build_dir: "./build", src_path: "./client"}))
.pipe(gulp.dest("./build"))
});
That will turn something like
<script src="file.js">
into
<script src="file.js?cbh=0123456789abcdef">
or
html {
background: url(image.jpg);
}
into
html {
background: url(image.jpg?cbh=0123456789abcdef);
}
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 missing files (default: false)
FAQs
Add hashes to links in HTML/CSS
The npm package gulp-hash-src receives a total of 0 weekly downloads. As such, gulp-hash-src popularity was classified as not popular.
We found that gulp-hash-src demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.