ElMassimo / vite-plugin-image-presets

🖼 Image Presets for Vite.js apps
https://image-presets.netlify.app/
MIT License
250 stars 5 forks source link

[Feature Request] Default preset #9

Open whaaaley opened 2 years ago

whaaaley commented 2 years ago

It would be nice if there were a way to specify a default preset so every import didn't need the query string.

Maybe something like this...

    imagePresets({
      'default': widthPreset({
        widths: [425, 1024, 1200],
        formats: {
          webp: { quality: 100 },
          png: { quality: 100 }
        }
      })
    }),

Or this...

    imagePresets({
      'foobar': widthPreset({
        default: true,
        widths: [425, 1024, 1200],
        formats: {
          webp: { quality: 100 },
          png: { quality: 100 }
        }
      })
    }),

Great plugin btw 👍 It's saved me a lot of time already.

ElMassimo commented 2 years ago

Hi Dustin, thanks for the suggestion!

That would involve processing every image referenced in the project, so wouldn't recommend it for most projects, but in smaller sites it might be a nice one to have.

Ideally, we would detect if there's a default preset during init, and use that flag to avoid these checks instead checking by image extension.

PRs are welcome!