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

fix(image): use defu for options and fix default format #166

Merged
merged 6 commits into from
Jan 27, 2021
Merged

fix(image): use defu for options and fix default format #166

merged 6 commits into from
Jan 27, 2021

Conversation

tresko
Copy link
Contributor

@tresko tresko commented Jan 27, 2021

  • Recursively apply default options
  • Copy modifiers object to ensure provider cannot have side-effects
  • Preserve target format to apply as default after getting image object from provider

When you run npx nuxt generate playground --force-build, only images in the original format are generated because the format field is removed from the options (src/runtime/image.ts#106) object.

This PR fixes it

Before:

✔ Generated static image playground/dist/_nuxt/image/71c8ed.jpg                                           @nuxt/image 10:25:44
✔ Generated static image playground/dist/_nuxt/image/361279.jpg                                           @nuxt/image 10:25:44
✔ Generated static image playground/dist/_nuxt/image/9fa6ff.jpg                                           @nuxt/image 10:25:44
✔ Generated static image playground/dist/_nuxt/image/904ad9.jpg                                           @nuxt/image 10:25:44
✔ Generated static image playground/dist/_nuxt/image/1b223b.jpg                                           @nuxt/image 10:25:44
✔ Generated static image playground/dist/_nuxt/image/049f76.jpg                                           @nuxt/image 10:25:44
✔ Generated static image playground/dist/_nuxt/image/bec44f.jpg                                           @nuxt/image 10:25:44
✔ Generated static image playground/dist/_nuxt/image/078043.jpg                                           @nuxt/image 10:25:44
✔ Generated static image playground/dist/_nuxt/image/8ab122.jpg                                           @nuxt/image 10:25:44
✔ Generated static image playground/dist/_nuxt/image/f833c8.jpg                                           @nuxt/image 10:25:44
✔ Generated static image playground/dist/_nuxt/image/a64002.jpg                                           @nuxt/image 10:25:44
✔ Generated static image playground/dist/_nuxt/image/1b7a64.jpg                                           @nuxt/image 10:25:44
✔ Generated static image playground/dist/_nuxt/image/552e88.jpg                                           @nuxt/image 10:25:44
✔ Generated static image playground/dist/_nuxt/image/4762de.jpg                                           @nuxt/image 10:25:44
✔ Generated static image playground/dist/_nuxt/image/900e5a.jpg                                           @nuxt/image 10:25:44
✔ Generated static image playground/dist/_nuxt/image/37b3ce.jpg                                           @nuxt/image 10:25:45
✔ Generated static image playground/dist/_nuxt/image/358c84.jpg 

After:

✔ Generated static image playground/dist/_nuxt/image/a64002.jpeg                                          @nuxt/image 10:29:14
✔ Generated static image playground/dist/_nuxt/image/1b7a64.jpeg                                          @nuxt/image 10:29:14
✔ Generated static image playground/dist/_nuxt/image/552e88.jpeg                                          @nuxt/image 10:29:14
✔ Generated static image playground/dist/_nuxt/image/904ad9.jpeg                                          @nuxt/image 10:29:14
✔ Generated static image playground/dist/_nuxt/image/4762de.jpeg                                          @nuxt/image 10:29:14
✔ Generated static image playground/dist/_nuxt/image/1b223b.jpeg                                          @nuxt/image 10:29:14
✔ Generated static image playground/dist/_nuxt/image/049f76.jpeg                                          @nuxt/image 10:29:14
✔ Generated static image playground/dist/_nuxt/image/8ab122.jpeg                                          @nuxt/image 10:29:14
✔ Generated static image playground/dist/_nuxt/image/078043.webp                                          @nuxt/image 10:29:14
✔ Generated static image playground/dist/_nuxt/image/361279.webp                                          @nuxt/image 10:29:14
✔ Generated static image playground/dist/_nuxt/image/900e5a.webp                                          @nuxt/image 10:29:14
✔ Generated static image playground/dist/_nuxt/image/358c84.webp                                          @nuxt/image 10:29:14
✔ Generated static image playground/dist/_nuxt/image/37b3ce.webp                                          @nuxt/image 10:29:14
✔ Generated static image playground/dist/_nuxt/image/bec44f.webp                                          @nuxt/image 10:29:14
✔ Generated static image playground/dist/_nuxt/image/f833c8.webp                                          @nuxt/image 10:29:14
✔ Generated static image playground/dist/_nuxt/image/71c8ed.webp                                          @nuxt/image 10:29:14
✔ Generated static image playground/dist/_nuxt/image/9fa6ff.jpg                                           @nuxt/image 10:29:14

src/runtime/providers/ipx.ts Outdated Show resolved Hide resolved
@farnabaz farnabaz requested a review from pi0 January 27, 2021 11:58
@pi0 pi0 changed the title fix(generate): fix format and options object manipulation fix(image): use defu for options and fix default format Jan 27, 2021
@pi0 pi0 merged commit cf2e9c1 into nuxt:main Jan 27, 2021
@pi0
Copy link
Member

pi0 commented Jan 27, 2021

Thanks @tresko @farnabaz for contribution ❤️

procrates pushed a commit to procrates/nuxt-image that referenced this pull request Feb 21, 2023
Co-authored-by: Farnabaz <farnabaz@gmail.com>
Co-authored-by: pooya parsa <pyapar@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants