feat: use wildcard excludes in Cloudflare Pages preset
๐ 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)
- [x] ๐ 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
routesusessatisfiesrather than a hardcoded type as it allows some non-null assertions to be removed _headersgeneration 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
- [x] I have linked an issue or discussion.
- [x] I have updated the documentation accordingly.
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 ๐๐ผ