fix: prevent ENAMETOOLONG for long Google Font URLs #583
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
π 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.