Skip to content

Commit

Permalink
feat: generate .assetsignore file for Cloudflare deployment (#13109)
Browse files Browse the repository at this point in the history
* .assetsignore file generation for Cloudflare deployment. It is corresponded to cloudflare/workers-sdk#6640

* move .assetsignore to files folder

* add .assetsignore file generation for adapter-cloudflare-workers

* changeset update

* move .gitignore per Ben McCann (benmccann) request

* Update .changeset/proud-taxis-admire.md

* Update .changeset/proud-taxis-admire.md

Co-authored-by: Tee Ming <chewteeming01@gmail.com>

* Revert "add .assetsignore file generation for adapter-cloudflare-workers"

This reverts commit 0e9b1fc.

* merge user's .assetsignore with the generated one

* Update proud-taxis-admire.md

remove mention of the unaffected package

* add ending newline to the generated .assetsignore

* move `.assetsignore` generation to generate_assetsignore()

* simplify the change

* cleanup unused import

* Update .changeset/proud-taxis-admire.md

---------

Co-authored-by: Timur Gamerov <methanoya@users.noreply.github.com>
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
  • Loading branch information
3 people authored Dec 19, 2024
1 parent b9dc4fd commit 8d6c469
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-taxis-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-cloudflare': minor
---

feat: generate `.assetsignore` file for use with Cloudflare Workers Static Assets
12 changes: 12 additions & 0 deletions packages/adapter-cloudflare/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ export default function (options = {}) {
}`
);
}

writeFileSync(`${dest}/.assetsignore`, generate_assetsignore(), { flag: 'a' });
},
async emulate() {
const proxy = await getPlatformProxy(options.platformProxy);
Expand Down Expand Up @@ -263,3 +265,13 @@ ${rules}
# === END AUTOGENERATED SVELTE PRERENDERED REDIRECTS ===
`.trimEnd();
}

function generate_assetsignore() {
// this comes from https://github.com/cloudflare/workers-sdk/blob/main/packages/create-cloudflare/templates-experimental/svelte/templates/static/.assetsignore
return `
_worker.js
_routes.json
_headers
_redirects
`;
}

0 comments on commit 8d6c469

Please sign in to comment.