feat: use wildcard excludes in Cloudflare Pages preset #2465
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.
π Linked issue
#2068
β Type of change
π Description
Cloudflare Pages has a 100 entry limit across
routes.include
androutes.exclude
. The way thatroutes.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:
routes
usessatisfies
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