-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
include as many static assets as possible in exclude list #8422
Conversation
🦋 Changeset detectedLatest commit: 579cee0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This reverts commit f3ff35f.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(not merging yet as we may want to wait on the CC'd person's response)
LGTM! Please do reach out if y'all have any issues. Follow-up - is it possible to configure sveltekit to have a single directory for all static files? e.g. |
Not really, no — it's common to use |
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Depends on what you mean by platform 404. In that case, the 404 behavior would be in control of the developer. Supposing we had a {
"exclude": ["/static/*"]
} And someone performed:
That means the request would bypass the Cloudflare Pages Function - i.e. the SvelteKit server - And passthrough to the Cloudflare Pages Asset Server where the default 404 behavior would kick-in. If the deployment provides a 404 page, that will get served up. Otherwise, the index page will be served by default (SPA-mode rendering). |
That would entail a new SvelteKit feature - we can create a 'fallback' page that in theory could be the In any case a user could theoretically have a The simplest thing by far for us - and I suspect most Cloudflare Pages users - would be a boolean that opted all static assets out of functions without messing around with |
Found an issue using this branch. It seems to add a lot of Here is the file it generates: https://pastebin.com/raw/4KqcrRwd I'm not sure if its related, but for some reason it doesnt seem to generate a _worker.js file? (causing the build to fail) |
@ajgeiss0702 I can't reproduce that, and I can't figure out how it could be happening. Any chance you can whip up a repro? |
(For the second thing, about not generating a |
Of course. Might take me a few days as I currently cannot share the repo that it is actively happening on so I'll need to extract some parts until I can reproduce the issue with a basic create-svelte project. My guess, glancing at the adapter's code, is that there is some condition where
Ah, I knew I was doing something wrong. Running that allowed it to build. |
It turns out I was able to reproduce it faster than I thought it would take. The issue occurs if the site has more than ~50 static assets (assets in the static folder and prerendered pages) In this repo, I basically just generated a bunch of prerendered pages until the issue occurred. Adding more assets to the static folder lowers the number of prerendered pages required for the issue to appear. |
Ah, I see what's happening — it's counting contents of |
When attempting to deploy to cloudflare pages, the build succeeds, but on the last step I get this:
It appears that the assets from the static folder are the ones that do not start with |
Seems like broken for routes that are NOT excluded (direct URL gives 404). @Rich-Harris FYI. |
If you need a sample repo to reproduce, please ping me and I will open the private repo. But looks like 101+ route with |
@korywka @ajgeiss0702 can you file an issue? I'm afraid comments on a closed PR are likely to get lost. Thanks for tracking down the cause though as that will be a big help! |
@benmccann done, thanks! |
@benmccann Rich fixed that problem right away in #8618 korywka's problem is separate from mine, so I agree that there should be an issue for that |
Is there a way to set those include/excludes manually? We have slug-urls that are longer than 100 characters (another limit of cloudflare) so that this PR breaks the build. Would be awesome to set (or generate) some include/exclude routes by pattern, so that we won't have that many characters for each route and instead just say |
Could you open a new issue for that? |
#8827 hope bug report was correct 🤷 |
closes #7640.
need to check that prerendered pages (with/without trailing slashes) will still work with this setup.cc @jrf0110 — this causes all static assets to bypass functions (or rather, as many as can fit in the
_routes.json
limit, which will be plenty for some but insufficient for others). I know you initially said you wanted people to be able to apply custom headers and so on, but a) the consensus seems to be that people want to avoid the cost of invoking functions for every request, and b) we don't currently have a way to add any custom logic when the worker serves a static file anyway, and I'm not aware of any requests for that behaviourPlease don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0