-
-
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
11 changed files
with
314 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'vite-imagetools': patch | ||
--- | ||
|
||
feat: caching of generated images |
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 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. | ||
The default retention is 1 day (86400 seconds). A value of 0 will disable this mechanism. | ||
|
||
``` | ||
// vite.config.js, etc | ||
... | ||
plugins: [ | ||
react(), | ||
imagetools({ | ||
cache: { | ||
enabled: true, | ||
dir: './node_modules/.cache/imagetools', | ||
retention: 172800 | ||
} | ||
}) | ||
] | ||
... | ||
``` |
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,63 @@ | ||
[imagetools](../README.md) / [Modules](../modules.md) / [vite/src/types](../modules/vite_src_types.md) / CacheOptions | ||
|
||
# Interface: CacheOptions | ||
|
||
[vite/src/types](../modules/vite_src_types.md).CacheOptions | ||
|
||
## Table of contents | ||
|
||
### Properties | ||
|
||
- [enabled](vite_src_types.CacheOptions.md#enabled) | ||
- [dir](vite_src_types.CacheOptions.md#dir) | ||
- [retention](vite_src_types.CacheOptions.md#retention) | ||
|
||
## Properties | ||
|
||
### enabled | ||
|
||
• **enabled**: `boolean` | ||
|
||
Wether caching of transformed images is enabled. | ||
|
||
**`Default`** | ||
|
||
```ts | ||
true | ||
``` | ||
|
||
#### Defined in | ||
|
||
[packages/vite/src/types.ts:104](https://github.com/JonasKruckenberg/imagetools/blob/4ebc88f/packages/vite/src/types.ts#L104) | ||
|
||
### dir | ||
|
||
• **dir**: `string` | ||
|
||
Where to store generated images on disk as cache. | ||
|
||
**`Default`** | ||
|
||
```ts | ||
'./node_modules/.cache/imagetools' | ||
``` | ||
|
||
#### Defined in | ||
|
||
[packages/vite/src/types.ts:109](https://github.com/JonasKruckenberg/imagetools/blob/4ebc88f/packages/vite/src/types.ts#L109) | ||
|
||
### retention | ||
|
||
• **retention**: `number` | ||
|
||
After what time an unused image will be removed from the cache. | ||
|
||
**`Default`** | ||
|
||
```ts | ||
86400 | ||
``` | ||
|
||
#### Defined in | ||
|
||
[packages/vite/src/types.ts:114](https://github.com/JonasKruckenberg/imagetools/blob/4ebc88f/packages/vite/src/types.ts#L114) |
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
3 changes: 3 additions & 0 deletions
3
...in-test-ts-vite-imagetools-import-with-space-in-identifier-and-cache-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.