Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@felixgabler
Copy link
Contributor

This prevents "Nuxt Build Error: [nuxt:fonts:font-family-injection] ENAMETOOLONG: name too long" for long Google Fonts file names

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ 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

This PR addresses an ENAMETOOLONG error that can occur during the build process when using @nuxt/fonts with variable fonts fetched from providers like Google Fonts (e.g., Roboto Flex).
The error arises because the current cache filename generation logic in setupPublicAssetStrategy includes a potentially very long identifier derived from the original font URL. In projects with deeper directory structures, the combination of the base path, the .nuxt/cache/fonts path, and this long filename prefix can exceed filesystem path length limits, causing the build to fail.
This change resolves the issue by truncating the URL-derived portion of the cache filename to a maximum of 50 characters. This significantly reduces the overall path length, preventing the error while still retaining some context from the original URL. The existing hash component of the filename ensures cache uniqueness remains intact.

This prevents "Nuxt Build Error: [nuxt:fonts:font-family-injection] ENAMETOOLONG: name too long" for long Google Fonts file names
@felixgabler felixgabler requested a review from danielroe as a code owner April 2, 2025 09:49
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 83.78%. Comparing base (89871f0) to head (35a8c8f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #583      +/-   ##
==========================================
+ Coverage   83.76%   83.78%   +0.01%     
==========================================
  Files          13       13              
  Lines        1072     1073       +1     
  Branches      271      271              
==========================================
+ Hits          898      899       +1     
  Misses        169      169              
  Partials        5        5              

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@danielroe danielroe merged commit cd6d11d into nuxt:main Apr 2, 2025
2 checks passed
This was referenced Mar 19, 2025
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