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 (#1237)
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 when trying to use --assets with a service-worker Worker",async()=>{
1449
+
writeWranglerToml({
1450
+
main: "./index.js",
1451
+
});
1452
+
writeWorkerSource({type: "sw"});
1453
+
awaitexpect(
1454
+
runWrangler("publish --assets abc")
1455
+
).rejects.toThrowErrorMatchingInlineSnapshot(
1456
+
`"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/"`
1457
+
);
1458
+
1459
+
expect(std).toMatchInlineSnapshot(`
1460
+
Object {
1461
+
"debug": "",
1462
+
"err": "[31mX [41;31m[[41;97mERROR[41;31m][0m [1mYou 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/[0m
1463
+
1464
+
",
1465
+
"out": "
1466
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m",
1467
+
"warn": "",
1468
+
}
1469
+
`);
1470
+
});
1471
+
1472
+
it("should error if --assets and --site are used together",async()=>{
1473
+
writeWranglerToml({
1474
+
main: "./index.js",
1475
+
});
1476
+
writeWorkerSource();
1477
+
awaitexpect(
1478
+
runWrangler("publish --assets abc --site xyz")
1479
+
).rejects.toThrowErrorMatchingInlineSnapshot(
1480
+
`"Cannot use Assets and Workers Sites in the same Worker."`
1481
+
);
1482
+
1483
+
expect(std).toMatchInlineSnapshot(`
1484
+
Object {
1485
+
"debug": "",
1486
+
"err": "[31mX [41;31m[[41;97mERROR[41;31m][0m [1mCannot use Assets and Workers Sites in the same Worker.[0m
1487
+
1488
+
",
1489
+
"out": "
1490
+
[32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose[0m",
1491
+
"warn": "",
1492
+
}
1440
1493
`);
1441
-
expect(std.err).toMatchInlineSnapshot(`""`);
1442
1494
});
1443
1495
1444
-
it("should error if --experimental-public and --site are used together",async()=>{
1496
+
it("should error if --assets and config.site are used together",async()=>{
0 commit comments