-
-
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
fix: copy _headers
and _redirects
from project root instead of /static
#13227
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 88c3008 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 |
preview: https://svelte-dev-git-preview-kit-13227-svelte.vercel.app/ this is an automated message |
So people would no longer do
they would put it in the root directly?
Do you remember why we did it originally by putting it in |
Yes, that's right.
I don't think it was ever intentional but it was the only way to have the files copied over to the root of the build output automatically without changes in the adapter. |
_headers
and _redirects
files need to be excluded from the service worker's files_headers
and _redirects
from project root instead of /static
I've changed it so that we copy the files from the project root now instead of relying on |
closes #12216
This PR documents the fact thatthe two Cloudflare Pages specific files need to be excluded from the service worker's files or the service worker will fail to register if it tries to add them to the cache. This is because the files are not publicly available after the app is deployed and the service worker will error if it can't find them from the internet.It would be nicer if we could use the adapter to exclude them but I don't know of an easy way to hook into the service worker build process or to modify the final output.Alternatively,we could stop encouraging_headers
and_redirects
files in the/static
directory as mentioned in the docs, and have the adapter read/copy them from the root of the project instead. Technically, they never should have been in the/static
directory since they are not meant to be public files. This would be a breaking change but it does fix this issue in a better way.Please 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. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits