Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dgrammatiko/lightningcss-url-version
https://github.com/dgrammatiko/lightningcss-url-version
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/dgrammatiko/lightningcss-url-version
- Owner: dgrammatiko
- License: mit
- Created: 2023-11-11T13:49:53.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-03-15T08:06:23.000Z (8 months ago)
- Last Synced: 2024-05-02T05:25:35.390Z (6 months ago)
- Language: JavaScript
- Size: 32.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lightningcss-url-version
[![GitHub issues](https://img.shields.io/github/issues/dgrammatiko/lightningcss-url-version)](https://github.com/dgrammatiko/lightningcss-url-version/issues)
[![GitHub license](https://img.shields.io/github/license/dgrammatiko/lightningcss-url-version)](https://github.com/dgrammatiko/lightningcss-url-version/blob/main/LICENSE)[![Twitter](https://img.shields.io/twitter/url?url=https%3A%2F%2Ftwitter.com%2Fdgrammatiko)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Fdgrammatiko%2Flightningcss-url-version)
lightningcss-url-version is a simple lightningcss plugin that adds a hash on every `url` property.
### Usage
install it:
```bash
npm i -D @dgrammatiko/lightningcss-plugin-url-version
```
Include it in your scripts:
```js
import UrlVersion from '@dgrammatiko/lightningcss-plugin-url-version';
```Use as any other lightningcss plugin:
```js
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 version
- `skipExternal`: skip URLS from an external domain
- `from`: the path to the current css fileeg:
```js
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