You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: --assets / config.assets to serve a folder of static assets
This adds support for defining `assets` in `wrangler.toml`. You can configure it with a string path, or a `{bucket, include, exclude}` object (much like `[site]`). This also renames the `--experimental-public` arg as `--assets`.
Via #1162
feat: `--assets` / `config.assets` to serve a folder of static assets
6
+
7
+
This adds support for defining `assets` in `wrangler.toml`. You can configure it with a string path, or a `{bucket, include, exclude}` object (much like `[site]`). This also renames the `--experimental-public` arg as `--assets`.
8
+
9
+
Via https://github.com/cloudflare/wrangler2/issues/1162
--host Host to forward requests to, defaults to the zone of project [string]
841
841
--local-protocol Protocol to listen to requests on, defaults to http. [choices: \\"http\\", \\"https\\"]
842
-
--experimental-public Static assets to be served [string]
842
+
--assets Static assets to be served [string]
843
843
--site Root folder of static assets for Workers Sites [string]
844
844
--site-include Array of .gitignore-style patterns that match file or directory names from the sites directory. Only matched items will be uploaded. [array]
845
845
--site-exclude Array of .gitignore-style patterns that match file or directory names from the sites directory. Matched items will not be uploaded. [array]
it("should error if --experimental-public and --site are used together",async()=>{
1443
+
it("should error when trying to use --assets with a service-worker Worker",async()=>{
1444
+
writeWranglerToml({
1445
+
main: "./index.js",
1446
+
});
1447
+
writeWorkerSource({type: "sw"});
1448
+
awaitexpect(
1449
+
runWrangler("publish --assets abc")
1450
+
).rejects.toThrowErrorMatchingInlineSnapshot(
1451
+
`"You cannot use the service-worker format with an \`assets\` directory yet. For information on how to migrate to the module-worker format, see https://developers.cloudflare.com/workers/learning/migrating-to-module-workers/"`
1452
+
);
1453
+
});
1454
+
1455
+
it("should error if --assets and --site are used together",async()=>{
"You cannot use the service-worker format with a `public` directory."
62
+
"You cannot use the service-worker format with an `assets` directory yet. For information on how to migrate to the module-worker format, see https://developers.cloudflare.com/workers/learning/migrating-to-module-workers/"
59
63
);
60
64
}
61
65
@@ -131,12 +135,12 @@ function DevSession(props: DevSessionProps) {
131
135
constbundle=useEsbuild({
132
136
entry: props.entry,
133
137
destination: directory,
134
-
staticRoot: props.public,
135
138
jsxFactory: props.jsxFactory,
136
139
rules: props.rules,
137
140
jsxFragment: props.jsxFragment,
138
-
// In dev for remote mode, we serve --experimental-assets from the local proxy before we send the request to the worker.
0 commit comments