Generating WebP images with nuxt-picture not working for static generated site (ssr:true,target:static)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 331
- Avg merge
- 19h 52m
- Merged PRs (30d)
- 9
Description
Nuxt version: 2.15.8
@nuxt/image version: 0.5.0
target: 'static',
ssr: true,
buildModules: [
['@nuxt/image'],
],
image: {
provider: 'static',
},
Using nuxt-picture with WebP type works in the dev mode. It generates images via _ipx. Here's a sample code from the dev mode that works:
This code (in dev mode)
nuxt-picture.image.image-desktop(
format="webp"
quality="80"
src="/images/xyz-header-large.jpg"
sizes="mobile:100vw tablet:100vw desktop:100vw widescreen:100vw fullhd:100vw"
)
will generate this code, which uses WebP images (in dev mode)
<source type="image/webp" srcset="/_ipx/images/xyz-header-large.jpg?w=768&f=webp&q=80 768w, /_ipx/images/xyz-header-large.jpg?w=769&f=webp&q=80 769w, /_ipx/images/xyz-header-large.jpg?w=1024&f=webp&q=80 1024w, /_ipx/images/xyz-header-large.jpg?w=1216&f=webp&q=80 1216w, /_ipx/images/xyz-header-large.jpg?w=1408&f=webp&q=80 1408w" sizes="(max-width: 768px) 100vw, (max-width: 769px) 100vw, (max-width: 1024px) 100vw, (max-width: 1216px) 100vw, 100vw">
However, when trying to generate a static site using yarn generate, the console output indicates that WebP images were created and indeed I can find them in _nuxt/image/ folder. But the generated static code does not link to WebP images, but uses the original "jpg" or "png" images instead.
Any help on this would be greatly appreciated.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Nuxt 2.15.8 configuration shown in the issue and run yarn generate using target: 'static', ssr: true, and the static image provider. Compare the generated static markup with the WebP files in _nuxt/image/. Done means nuxt-picture output references the generated WebP images instead of the original JPG or PNG files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxt, typescript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100