image icon indicating copy to clipboard operation
image copied to clipboard

feat: added image dir support for nuxt layer

Open wuiyang opened this issue 5 months ago โ€ข 2 comments

๐Ÿ”— Linked issue

resolves #1879

โ“ Type of change

  • [ ] ๐Ÿ“– Documentation (updates to the documentation or readme)
  • [ ] ๐Ÿž Bug fix (a non-breaking change that fixes an issue)
  • [x] ๐Ÿ‘Œ Enhancement (improving an existing functionality)
  • [ ] โœจ New feature (a non-breaking change that adds functionality)
  • [ ] ๐Ÿงน Chore (updates to the build process or auxiliary tools and libraries)
  • [ ] โš ๏ธ Breaking change (fix or feature that would cause existing functionality to change)

๐Ÿ“š Description

For Nuxt project that uses IPX provider, it would not search nuxt layer's custom dir.

This changes allows Nuxt project with local layers to look for image in layer's dir.

Note: with this changes, similar to root nuxt config with custom dir, would not work for runtime IPX, and only works for ipxStatic provider.

Note 2: As nuxt.options compiles all layer's config, if root is using default config (not providing any), it will have layer's dir value. The image dir config will retrieve from layer's config instead to prevent this issue.

-    const path = isRootLayer ? moduleOptions.dir : layer.config.dir?.public || 'public'
+    const path = layer?.config.image?.dir || layer.config.dir?.public || 'public'

wuiyang avatar Jun 25 '25 16:06 wuiyang

@wuiyang is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Jun 25 '25 16:06 vercel[bot]

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/image@1880

commit: 165ae13

pkg-pr-new[bot] avatar Jun 25 '25 16:06 pkg-pr-new[bot]

this is great - thank you! โค๏ธ

would you add unit tests in ssr.test.ts and no-ssr.test.ts, e.g.:

https://github.com/nuxt/image/blob/aaeb7d5cfafc0a2ce5a4feea0a9486a177876363/test/e2e/ssr.test.ts#L58-L72

Thank you for the feedback, I couldn't get e2e test to run on my end, not sure if I setup something wrong, I'm using github codespaces to work on the PR

wuiyang avatar Jul 05 '25 18:07 wuiyang

fixed the test suite! you should be able to run e2e tests now....

danielroe avatar Jul 10 '25 11:07 danielroe

Codecov Report

:x: Patch coverage is 0% with 24 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 7.03%. Comparing base (bf778b5) to head (165ae13).

Files with missing lines Patch % Lines
src/module.ts 0.00% 21 Missing :warning:
src/ipx.ts 0.00% 3 Missing :warning:
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #1880      +/-   ##
========================================
- Coverage   7.06%   7.03%   -0.03%     
========================================
  Files         77      77              
  Lines       3555    3569      +14     
  Branches     138     138              
========================================
  Hits         251     251              
- Misses      3256    3270      +14     
  Partials      48      48              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov-commenter avatar Jul 10 '25 11:07 codecov-commenter

apologize for slow update on PR, was busy with work for the last month and now got the time to add test into it

wuiyang avatar Aug 04 '25 10:08 wuiyang

The latest updates on your projects. Learn more about Vercel for Git โ†—๏ธŽ

1 Skipped Deployment
Name Status Preview Updated (UTC)
image-docus โฌœ๏ธ Ignored (Inspect) Aug 4, 2025 10:46am

vercel[bot] avatar Aug 04 '25 10:08 vercel[bot]