A build plugin to make building with Eleventy and Netlify a joy!
- Caches images generated by @11ty/eleventy-img across builds
- Caches assets fetched by @11ty/eleventy-cache-assets across builds
- Caches any other folders your choice (optional)
Install plugin via npm as dependency:
Note: Till 11ty/eleventy-img#116 is merged, please use this fork instead of @11ty/eleventy-img.
npm uninstall @11ty/eleventy-img npm install zeroby0/eleventy-img#cache npm install zeroby0/netlify-plugin-11tyAnd add the plugin to your netlify.toml file
[[plugins]] package = "netlify-plugin-11ty"Optionally, you can configure the plugin to suit your project's needs.
Example:
[[plugins]] package = "netlify-plugin-11ty" [plugins.inputs] cache_img = './img' cache_img_httpHeader = true cache_assets = '../.cache' cache_other = []The following inputs options are available:
Type: String or Array of Strings
Default: './img' (relative to the publish directory)
The folder(s) in which files generated by @11ty/eleventy-img are stored, relative to publish directory. Can be a string or an array of strings.
If set to false, files generated by @11ty/eleventy-img are not saved in Netlify cache.
Type: Boolean
Default: true
If set to true, a files generated by @11ty/eleventy-img will be served with http header cache-control: public, max-age=31536000, immutable.
This should be safe to do as the file names have a hash calculated using file content and Sharp Options.
Type: String or Array of Strings
Default: '../.cache' (relative to the publish directory)
The folder(s) in which remote assets fetched by @11ty/eleventy-cache-assets are cached, relative to publish directory. Can be a string or an array of strings.
If set to false, assets fetched by @11ty/eleventy-cache-assets are not saved in Netlify cache.
Type: String or Array of Strings
Default: [] (relative to the publish directory)
Any other folder(s) you'd like to cache across Netlify builds. If these folders exist before restoring Nelify cache, they will be replaced with cached folders.
| Run | No cache persistence | With cache persistence |
|---|---|---|
| 1st run (empty cache) | 11.74 seconds | 11.52 seconds |
| 2nd run (filled cache) | 11.32 seconds | 131.82 milliseconds |
Please create an issue :)
MIT
If you need this repository with a different License, please create an issue.