From 1cdbadb9c0ad031430214f4d21b9012ac8eec1b0 Mon Sep 17 00:00:00 2001 From: Gabbi Fisher Date: Mon, 7 Oct 2019 14:09:32 -0700 Subject: [PATCH 1/3] Add new docs for wrangler include/exclude --- content/sites/ignore-assets.md | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 content/sites/ignore-assets.md diff --git a/content/sites/ignore-assets.md b/content/sites/ignore-assets.md new file mode 100644 index 000000000..53f199a23 --- /dev/null +++ b/content/sites/ignore-assets.md @@ -0,0 +1,36 @@ +--- +title: Ignoring Subsets of Static Assets +alwaysopen: true +weight: 5 +--- + +Worker Sites require [Wrangler](https://github.com/cloudflare/wrangler) - make sure to be on the [latest version](/quickstart/#updating-the-cli) - and the Workers [Unlimited plan](https://workers.cloudflare.com/sites#plans). + +There are cases where users may not want to upload certain static assets to their Workers Sites. +In this case, Workers Sites can also be configured to ignore certain files or directories using logic +similar to [Cargo's optional include and exclude fields](https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields-optional). +This means that we use gitignore semantics when declaring which directory entries to include or ignore in uploads. + +If you want to include only a certain set of files or directories in your `bucket`, you can add an `include` field to your +`[site]` section of `wrangler.toml`: +```toml +[site] +bucket = "./public" +entry-point = "workers-site" +include = ["included_dir"] # must be an array. +``` +Wrangler will only upload files or directories matching the patterns in the `include` array. + +If you want to exclude files or directories in your `bucket`, you can add an `exclude` field to your +`[site]` section of `wrangler.toml`: +```toml +[site] +bucket = "./public" +entry-point = "workers-site" +exclude = ["excluded_dir"] # must be an array. +``` +Wrangler will ignore files or directories matching the patterns in the `exclude` array when uploading assets to Wrangler. + +If you provide both an `include` and `exclude` field, the `include` field will be used and the `exclude` field will be ignored. + +You can learn more about the standard patterns used for include and exclude in the [gitignore documentation](https://git-scm.com/docs/gitignore). \ No newline at end of file From fc2155600f6f5fe8ef1d69345ee2b2460f1d0b9b Mon Sep 17 00:00:00 2001 From: Gabbi Fisher Date: Mon, 7 Oct 2019 14:10:55 -0700 Subject: [PATCH 2/3] small fix --- content/sites/ignore-assets.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/sites/ignore-assets.md b/content/sites/ignore-assets.md index 53f199a23..3ee79bd65 100644 --- a/content/sites/ignore-assets.md +++ b/content/sites/ignore-assets.md @@ -31,6 +31,6 @@ exclude = ["excluded_dir"] # must be an array. ``` Wrangler will ignore files or directories matching the patterns in the `exclude` array when uploading assets to Wrangler. -If you provide both an `include` and `exclude` field, the `include` field will be used and the `exclude` field will be ignored. +If you provide both `include` and `exclude` fields, the `include` field will be used and the `exclude` field will be ignored. You can learn more about the standard patterns used for include and exclude in the [gitignore documentation](https://git-scm.com/docs/gitignore). \ No newline at end of file From 04d55cec010eb59cdfca737f160258e725a896cd Mon Sep 17 00:00:00 2001 From: Gabbi Fisher Date: Mon, 7 Oct 2019 14:21:17 -0700 Subject: [PATCH 3/3] include required ignore seciton --- content/sites/ignore-assets.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/content/sites/ignore-assets.md b/content/sites/ignore-assets.md index 3ee79bd65..22b5e1d22 100644 --- a/content/sites/ignore-assets.md +++ b/content/sites/ignore-assets.md @@ -11,6 +11,8 @@ In this case, Workers Sites can also be configured to ignore certain files or di similar to [Cargo's optional include and exclude fields](https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields-optional). This means that we use gitignore semantics when declaring which directory entries to include or ignore in uploads. +### Exclusively including files/directories + If you want to include only a certain set of files or directories in your `bucket`, you can add an `include` field to your `[site]` section of `wrangler.toml`: ```toml @@ -21,6 +23,8 @@ include = ["included_dir"] # must be an array. ``` Wrangler will only upload files or directories matching the patterns in the `include` array. +### Excluding files/directories + If you want to exclude files or directories in your `bucket`, you can add an `exclude` field to your `[site]` section of `wrangler.toml`: ```toml @@ -31,6 +35,17 @@ exclude = ["excluded_dir"] # must be an array. ``` Wrangler will ignore files or directories matching the patterns in the `exclude` array when uploading assets to Wrangler. +### Include > Exclude + If you provide both `include` and `exclude` fields, the `include` field will be used and the `exclude` field will be ignored. +### Default ignored entries + +Wrangler will always ignore +* `node_modules` +* Hidden files and directories +* Symlinks + +### More about include/exclude patterns + You can learn more about the standard patterns used for include and exclude in the [gitignore documentation](https://git-scm.com/docs/gitignore). \ No newline at end of file