Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to configure cache directory for image conversions in @sveltejs/enhanced-img #12615

Open
mglinski opened this issue Aug 26, 2024 · 0 comments

Comments

@mglinski
Copy link

mglinski commented Aug 26, 2024

Describe the problem

Using the @sveltejs/img:enhanced package generates a large number of cacheable converted image variants in various sizes/formats. This process also takes a long time to run the more images are processed and the more variants that are requested.

The vite-imagetools plugin supports caching these artifacts, which @sveltejs/img:enhanced also supports as of v0.2

It does not seem to be possible to use the configuration options that are built into the vite-imagetools plugin to specify where these cached build artifacts should be saved though when using @sveltejs/img:enhanced.

Describe the proposed solution

I would like to be able to configure the upstream vite-imagetools cache options for use in @sveltejs/enhanced:img.

The upstream PR is here and the documented configuration object for cache options is here.

Perhaps having a config passthrough in the vite.config.js file could be an acceptable solution?

import { enhancedImages } from '@sveltejs/enhanced-img';
export default defineConfig({
  ...
  plugins: [
    enhancedImages({
      cache: {
        dir: './node_modules/.cache/imagetools'
      }
    })
    ...
  ]
});

Alternatives considered

I have setup a cache using the default location that vite-imagetools uses but I would like to manually specify the cache location and bring it outside of the node_modules folder.

Importance

nice to have

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
@mglinski @benmccann and others