[ ] π 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 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).
π 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 thegenerateExcludes
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