@dgrammatiko/lightningcss-url-version
v1.0.1
Published
A simple lightningcss plugin that adds a hash on every relative url property
Downloads
5
Maintainers
Readme
lightningcss-url-version
lightningcss-url-version is a simple lightningcss plugin that adds a hash on every url
property.
Usage
install it:
npm i -D @dgrammatiko/lightningcss-plugin-url-version
Include it in your scripts:
import UrlVersion from '@dgrammatiko/lightningcss-plugin-url-version';
Use as any other lightningcss plugin:
const { code } = transform({
minify: true,
code: Buffer.from('...'),
visitor: composeVisitors([urlVersioning({ from: 'the/path/to/the/current/file.css'})]),
});
Options
There are 4 options, version
and variable
, skipExternal
and from
:
version
: a function that returns a string for the hash (NOT an arrow function!)variable
: could be a a string denoting the URLparam that will be used for the versionskipExternal
: skip URLS from an external domainfrom
: the path to the current css file
eg:
import UrlVersion from 'lightningcss-plugin-url-version';
const { code } = transform({
minify: true,
code: Buffer.from('...'),
visitor: composeVisitors([urlVersioning(opts)]),
});
// Will produce something like url(files/16761/star.gif?v=1614866396902);
License MIT