-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: generate .assetsignore
file for Cloudflare deployment
#13109
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
Merged
teemingc
merged 15 commits into
sveltejs:main
from
methanoya:issue-13108-cloudflare-assetsignore-support
Dec 19, 2024
Merged
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
14b662f
.assetsignore file generation for Cloudflare deployment. It is corres…
methanoya 32ccc2e
move .assetsignore to files folder
methanoya 0e9b1fc
add .assetsignore file generation for adapter-cloudflare-workers
methanoya ee1e4bb
changeset update
methanoya 6892797
move .gitignore per Ben McCann (benmccann) request
methanoya 9061fc5
Update .changeset/proud-taxis-admire.md
teemingc 1259966
Update .changeset/proud-taxis-admire.md
methanoya ae98415
Revert "add .assetsignore file generation for adapter-cloudflare-work…
methanoya 38a0220
merge user's .assetsignore with the generated one
methanoya 896318c
Update proud-taxis-admire.md
methanoya 3b27f87
add ending newline to the generated .assetsignore
methanoya 99d2fd9
move `.assetsignore` generation to generate_assetsignore()
methanoya a1ec57a
simplify the change
methanoya 728fb08
cleanup unused import
methanoya 68bdb25
Update .changeset/proud-taxis-admire.md
teemingc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
_worker.js | ||
_routes.json | ||
_headers | ||
_redirects |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
_worker.js | ||
_routes.json | ||
_headers | ||
_redirects |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
teemingc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
!.assetsignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Seems like we would need #13072 to be merged first, then copy the
.assetsignore
file to the root of theassets
folder.https://developers.cloudflare.com/workers/static-assets/binding/#ignoring-assets
I'm also wondering if we would want to simply append / write to a file instead of copying so that a user's
.assetsignore
file would be taken into consideration. Similar tokit/packages/adapter-cloudflare/index.js
Line 69 in 01d2720
_headers
to the file.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.
It looks like #13072 is in a draft state, this PR is ready to use.
The source of the
.assetsignore
is https://github.com/cloudflare/workers-sdk/blob/main/packages/create-cloudflare/templates-experimental/svelte/js/static/.assetsignore They created it some way, so it makes sense to keep it the same and copy from there if updated. It is a better point to control the list of server-side-only files. Another approach is adding files like_worker.js
to the.assetsignore
once they are created, but it is probably less clear. Let me know if you have a strong opinion, I will update the PR accordingly.Uh oh!
There was an error while loading. Please reload this page.
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.
The difference is that Cloudflare's
.assetsignore
file is part of a starting template, whereas we need to take into account a user having their own file. I'd recommend that we write using append mode so it's created if it doesn't exist, otherwise it writes to the existing file.I'm also not sure copying it to
main
corresponds to the root of the assets directory. Isn't it currentlysite.bucket
?kit/packages/adapter-cloudflare-workers/index.js
Lines 146 to 149 in 33600ee
But I'm also not sure if copying it to the bucket root would have any effect since it's part of the old Workers sites feature. cc: @petebacondarwin
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.
What about a shipping update for
adapter-cloudflare
only since it would work differently foradapter-cloudflare-workers
and can depend on #13072 ?Uh oh!
There was an error while loading. Please reload this page.
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.
Making
.assetsignore
based on an existing one can be a good idea, but it looks likeadapter-cloudflare
takes responsibility for making the right bundle for the Cloudflare deployment. I am not sure that a user can have a reason to make any non-asset file.We can show a warning message if
.assetsignore
is already present as a current workaround.I am open to both approaches if maintainers strongly believe either way.
Uh oh!
There was an error while loading. Please reload this page.
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.
Yeah, I think we can probably split the Workers part into another PR.
The main purpose of the file is to prevent certain assets from being made public. This can be desirable if the user has server only assets. I think we should append to an existing
.assetsignore
fileThere 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.
@eltigerchino I have removed the
-workers
code from the PR and added.assetsignore
merging. It may be overcomplicated, and we would need to add just one file to another. Let me know your thoughts.