unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
5.89k stars 496 forks source link

feat: use wildcard excludes in Cloudflare Pages preset #2465

Open Brendonovich opened 4 months ago

Brendonovich commented 4 months ago

πŸ”— Linked issue

2068

❓ Type of 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:

πŸ“ Checklist

pi0 commented 3 days ago

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 πŸ™πŸΌ