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

feat: use wildcard excludes in Cloudflare Pages preset #2465

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Brendonovich
Copy link

@Brendonovich Brendonovich commented May 24, 2024

πŸ”— Linked issue

#2068

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ 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

Cloudflare Pages has a 100 entry limit across routes.include and routes.exclude. The way that routes.exclude is currently generated makes that limit get hit pretty quickly, since each file to be excluded is listed individually. Thankfully, CF supports using wildcards to exclude whole folders and way more than 100 files.
This PR adds the generateExcludes function, which attempts to combine as many of the excluded files into wildcard paths as possible, taking into account directories that contain files that have been marked specifically as non-excludable.

This setup has been working for us at Mattrax for a while, but generateExcludes probably needs more testing and possibly some unit tests.

Resolves #2068

Also made some smaller changes:

  • The declaration of routes uses satisfies rather than a hardcoded type as it allows some non-null assertions to be removed
  • _headers generation ignores values set for the same headers for previous sets of routes, since I don't get the impression that headers from routeRules are intended to be additive. We rely on this as we have cache settings at /* that we override for certain routes (and would like nitro to override).

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@pi0
Copy link
Member

pi0 commented Sep 24, 2024

Thanks for PR dear @Brendonovich and sorry for late reply.

I think in order to move it forward, it would be better if we add couple of unit tests and if possible, break it down to smaller changes πŸ™πŸΌ

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.

Too many items generated in _route.json for cloudflare preset
2 participants