Skip to content

Commit

Permalink
document Workers Static Assets .assetsignore file (cloudflare#18605)
Browse files Browse the repository at this point in the history
* document Workers Static Assets .assetsignore file

* Update src/content/docs/workers/static-assets/binding.mdx

Co-authored-by: WillTaylorDev <[email protected]>

---------

Co-authored-by: WillTaylorDev <[email protected]>
  • Loading branch information
petebacondarwin and WillTaylorDev authored Dec 7, 2024
1 parent 0e0135c commit 35577e2
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/content/docs/workers/static-assets/binding.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,32 @@ assets = { directory = "./public/" }

</WranglerConfig>

## `binding`
### Ignoring assets

Configuring the optional [binding](/workers/runtime-apis/bindings) gives you access to the collection of assets from within your Worker script.
Sometime there are files in the asset directory that should not be uploaded.

In this case, create a `.assetsignore` file in the root of the assets directory.
This file takes the same format as `.gitignore`.

Wrangler will not upload asset files that match lines in this file.

**Example**

You are migrating from a Pages project where the assets directory is `dist`.
You do not want to upload the server-side Worker code nor Pages configuration files as public client-side assets.
Add the following `.assetsignore` file:

```gitignore
_worker.js
_redirects
_headers
```

Now Wrangler will not upload these files as client-side assets when deploying the Worker.

## `binding`

Configuring the optional [binding](/workers/runtime-apis/bindings) gives you access to the collection of assets from within your Worker script.

<WranglerConfig>

Expand Down

0 comments on commit 35577e2

Please sign in to comment.