-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
231 changed files
with
8,338 additions
and
7,523 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Caching | ||
|
||
To speed up a build pipeline with many images, the generated images can be cached on disk. | ||
If the source image changes, the cached images will be regenerated. | ||
|
||
## How to configure caching | ||
|
||
Caching is enabled by default and uses './node_modules/.cache/imagetools' as the cache directory. | ||
You can disable caching or change the directory with options. | ||
|
||
``` | ||
// vite.config.js, etc | ||
... | ||
plugins: [ | ||
react(), | ||
imagetools({ | ||
cache: { | ||
enabled: true, | ||
dir: './node_modules/.cache/imagetools' | ||
} | ||
}) | ||
] | ||
... | ||
``` | ||
|
||
## Cache retention to remove unused images | ||
|
||
When an image is no longer there or the transformation parameters change, the previously | ||
cached images will be removed after a configurable retention period. | ||
A value of `undefined` will disable this mechanism, which is the default. | ||
|
||
``` | ||
// vite.config.js, etc | ||
... | ||
plugins: [ | ||
react(), | ||
imagetools({ | ||
cache: { | ||
enabled: true, | ||
dir: './node_modules/.cache/imagetools', | ||
retention: 172800 | ||
} | ||
}) | ||
] | ||
... | ||
``` |
Oops, something went wrong.