postcss-url-version
v1.0.5
Published
A simple PostCSS plugin that adds a hash on every url property
Downloads
38
Maintainers
Readme
postcss-url-version
Postcss-url-version is a simple PostCSS plugin that adds a hash on every url
property.
Usage
install it:
npm i -D postcss-url-version
Include it in your scripts:
const UrlVersion = require('postcss-url-version');
Use as any other PostCSS plugin:
Postcss([Autoprefixer, UrlVersion])...
Options
There are 2 options, version
and variable
:
version
a function that returns a string for the hashvariable
could be a a string denoting the URLparam that will be used for the version
eg:
const UrlVersion = require('postcss-url-version');
const versioned = UrlVersion({
// The path of the asset relative to the css is passed as argument to the function,
// so you can hash the content of the file for a better invalidation strategy
version: (path) => new Date().valueOf().toString(),
variable: 'v',
});
Postcss([versioned])...
// Will produce something like url("https://mdn.mozillademos.org/files/16761/star.gif?v=1614866396902");
License MIT