Skip to content

Commit

Permalink
feat: support clearCache on local provider
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Sep 24, 2020
1 parent 0d6421a commit ba239a4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/content/en/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ Complete list of internal providers.

Local provider is an integration of ipx and image module. Local provider is an specific provider that uses for development, optimizing in-project.
By default local provider looks `static` dir to find original images, You can change `dir` inside `nuxt.config`.
The local provider has a chaching stategy to clear cached images to reduce massive disk usages. You can schedule the cache cleaning job using `clearCache` option in provide options. By default this cron job is disabled.

```js{}[nuxt.config.js]
export default {
image: {
providers: {
local: {
dir: '~/assets/images/local'
dir: '~/assets/images/local',
clearCache: false
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/providers/local/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ function createMiddleware(options) {
adapter: 'fs',
dir: options.dir
},
cache: {
cleanCron: options.clearCache || false,
}
});
return IPXMiddleware(ipx)
}
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type ProviderServerMiddleware = (req, res, next) => void

export interface LocalOptions {
dir?: string
clearCache?: boolean | string;
}

export interface GenerateOptions {
Expand Down

0 comments on commit ba239a4

Please sign in to comment.