https://github.com/pirxpilot/postcss-cachify
PostCSS plugin to replace assets urls with cachified versions.
https://github.com/pirxpilot/postcss-cachify
Last synced: 12 months ago
JSON representation
PostCSS plugin to replace assets urls with cachified versions.
- Host: GitHub
- URL: https://github.com/pirxpilot/postcss-cachify
- Owner: pirxpilot
- License: mit
- Created: 2015-03-09T17:14:59.000Z (over 11 years ago)
- Default Branch: main
- Last Pushed: 2023-10-17T19:50:53.000Z (almost 3 years ago)
- Last Synced: 2024-11-11T11:30:14.879Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 26.4 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
[![NPM version][npm-image]][npm-url]
[![Build Status][build-image]][build-url]
[![Dependency Status][deps-image]][deps-url]
# PostCSS Cachify
[PostCSS] plugin to replace assets urls with cachified versions. Companion for [connect-cachify-static] - rewritten URLs allow for long cache expiration and reliable cache busting for resources referenced in CSS files.
```css
.cachified-relative {
background-image: url('/image.png');
}
.cachified-absolute {
background-image: url('image.png');
}
```
```css
.cachified-relative {
background-image: url('/97ea519347/image.png');
}
.cachified-absolute {
background-image: url('/97ea519347/image.png');
}
```
## Options
- `baseUrl` - defaults to `/` - used to convert relative URLs to absolute URLs
- `basePath` - location of files that will be cachified - defaults to current working directory
- `match` - regular expression used to filter out files that will be considered for cachifying - defaults to `/\.(svg|eot|woff|ttf|png|gif|jpg)$/`
- `format` - `name`, `path` or function converting `path` and `hash` prefix into cachified name - defaults to `path`
## Usage
```js
postcss([ require('postcss-cachify') ]);
```
See [PostCSS] docs for examples for your environment.
[PostCSS]: https://github.com/postcss/postcss
[connect-cachify-static]: https://github.com/pirxpilot/connect-cachify-static
[npm-image]: https://img.shields.io/npm/v/postcss-cachify
[npm-url]: https://npmjs.org/package/postcss-cachify
[build-url]: https://github.com/pirxpilot/postcss-cachify/actions/workflows/check.yaml
[build-image]: https://img.shields.io/github/actions/workflow/status/pirxpilot/postcss-cachify/check.yaml?branch=main
[deps-image]: https://img.shields.io/librariesio/release/npm/postcss-cachify
[deps-url]: https://libraries.io/npm/postcss-cachify