https://github.com/denperidge/eleventy-auto-cache-buster
An Eleventy content-hash based cache buster, not requiring any filters or code changes aside from enabling the plugin!
https://github.com/denperidge/eleventy-auto-cache-buster
eleventy eleventy-plugin
Last synced: about 1 month ago
JSON representation
An Eleventy content-hash based cache buster, not requiring any filters or code changes aside from enabling the plugin!
- Host: GitHub
- URL: https://github.com/denperidge/eleventy-auto-cache-buster
- Owner: Denperidge
- License: mit
- Created: 2023-12-01T10:51:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-27T11:53:32.000Z (8 months ago)
- Last Synced: 2024-11-07T12:02:30.660Z (7 months ago)
- Topics: eleventy, eleventy-plugin
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/eleventy-auto-cache-buster
- Size: 1.65 MB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Eleventy-Auto-Cache-Buster
An Eleventy content-hash based cache buster, not requiring any filters or code changes aside from adding the plugin in `.eleventy.js`!Turn...
```html```
Into...
```html```
## How-to
### Getting started
1. Install the plugin
- Yarn: `yarn add -D eleventy-auto-cache-buster`
- Npm: `npm install --save-dev eleventy-auto-cache-buster`
2. Enable the plugin
```js
// .eleventy.js
const eleventyAutoCacheBuster = require("eleventy-auto-cache-buster");
// Alternatively, you can use ESM
import eleventyAutoCacheBuster from "eleventy-auto-cache-buster";module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(eleventyAutoCacheBuster);
// ...
}
```
3. That's it! No further changes are required.### Changing options
```js
// .eleventy.js
const eleventyAutoCacheBuster = require("eleventy-auto-cache-buster");module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(eleventyAutoCacheBuster, {
enableLogging: true, // Whether to enable eleventy-auto-cache-buster logging.
hashTruncate: 0, // Desired substring length of the hash. Set to 0 or lower to disable truncating
runAsync: false, // Whether to run asynchronously. Default is true
globstring: "subdir/**/*", // What glob string is used to locate assets.
globOptions: {nodir: true, ignore: ['node_modules/**', 'tmp/**']} // exclude multiple files or directories. (NOTE: `nodir` will automatically be set to true). Reference: https://github.com/isaacs/node-glob#readme
extensions: ["css"], // What file extensions are accepted when locating assets.
hashAlgorithm: "sha1", // What hash method to pass to the hash function. See Node.js' crypto.createHash documentation.
hashFunction: function (content) { return "example" } // What function to run to calculate hashes. Overrides hashAlgorithm.
});
// ...
}
```## License
This project is licensed under the [MIT License](LICENSE).