From 1cf878b51926e16d44ea8d6f4162b42cd23acb50 Mon Sep 17 00:00:00 2001 From: Thomas Gauvin Date: Mon, 3 Feb 2025 22:16:36 -0500 Subject: [PATCH] thomasgauvin WIP separate wrangler docs --- .../hyperdrive/examples/prisma-postgres.mdx | 28 ++ .../docs/{workers => }/wrangler/api.mdx | 18 +- .../wrangler => wrangler/builds}/bundling.mdx | 2 + .../builds}/custom-builds.mdx | 21 +- src/content/docs/wrangler/builds/index.mdx | 16 + .../docs/{workers => }/wrangler/commands.mdx | 16 +- .../configuration/configuration-file.mdx} | 13 +- .../configuration}/environments.mdx | 8 +- .../docs/wrangler/configuration/index.mdx | 18 ++ .../system-environment-variables.mdx | 57 ++-- .../docs/{workers => }/wrangler/index.mdx | 7 +- .../wrangler/install-and-update.mdx | 2 +- .../reference}/deprecations.mdx | 0 src/content/docs/wrangler/reference/index.mdx | 15 + .../reference}/migration/index.mdx | 0 .../reference}/migration/update-v2-to-v3.mdx | 0 .../migration/v1-to-v2/eject-webpack.mdx | 0 .../reference}/migration/v1-to-v2/index.mdx | 0 .../migration/v1-to-v2/update-v1-to-v2.mdx | 0 .../wrangler-legacy/authentication.mdx | 2 +- .../v1-to-v2/wrangler-legacy/commands.mdx | 4 +- .../wrangler-legacy/configuration.mdx | 295 +++++++----------- .../v1-to-v2/wrangler-legacy/index.mdx | 5 +- .../wrangler-legacy/install-update.mdx | 2 +- .../v1-to-v2/wrangler-legacy/webpack.mdx | 59 ++-- src/content/products/wrangler.yaml | 28 ++ src/icons/wrangler.svg | 1 + src/util/sidebar.ts | 3 +- 28 files changed, 324 insertions(+), 296 deletions(-) create mode 100644 src/content/docs/hyperdrive/examples/prisma-postgres.mdx rename src/content/docs/{workers => }/wrangler/api.mdx (96%) rename src/content/docs/{workers/wrangler => wrangler/builds}/bundling.mdx (99%) rename src/content/docs/{workers/wrangler => wrangler/builds}/custom-builds.mdx (77%) create mode 100644 src/content/docs/wrangler/builds/index.mdx rename src/content/docs/{workers => }/wrangler/commands.mdx (99%) rename src/content/docs/{workers/wrangler/configuration.mdx => wrangler/configuration/configuration-file.mdx} (99%) rename src/content/docs/{workers/wrangler => wrangler/configuration}/environments.mdx (99%) create mode 100644 src/content/docs/wrangler/configuration/index.mdx rename src/content/docs/{workers/wrangler => wrangler/configuration}/system-environment-variables.mdx (71%) rename src/content/docs/{workers => }/wrangler/index.mdx (73%) rename src/content/docs/{workers => }/wrangler/install-and-update.mdx (97%) rename src/content/docs/{workers/wrangler => wrangler/reference}/deprecations.mdx (100%) create mode 100644 src/content/docs/wrangler/reference/index.mdx rename src/content/docs/{workers/wrangler => wrangler/reference}/migration/index.mdx (100%) rename src/content/docs/{workers/wrangler => wrangler/reference}/migration/update-v2-to-v3.mdx (100%) rename src/content/docs/{workers/wrangler => wrangler/reference}/migration/v1-to-v2/eject-webpack.mdx (100%) rename src/content/docs/{workers/wrangler => wrangler/reference}/migration/v1-to-v2/index.mdx (100%) rename src/content/docs/{workers/wrangler => wrangler/reference}/migration/v1-to-v2/update-v1-to-v2.mdx (100%) rename src/content/docs/{workers/wrangler => wrangler/reference}/migration/v1-to-v2/wrangler-legacy/authentication.mdx (98%) rename src/content/docs/{workers/wrangler => wrangler/reference}/migration/v1-to-v2/wrangler-legacy/commands.mdx (99%) rename src/content/docs/{workers/wrangler => wrangler/reference}/migration/v1-to-v2/wrangler-legacy/configuration.mdx (77%) rename src/content/docs/{workers/wrangler => wrangler/reference}/migration/v1-to-v2/wrangler-legacy/index.mdx (63%) rename src/content/docs/{workers/wrangler => wrangler/reference}/migration/v1-to-v2/wrangler-legacy/install-update.mdx (97%) rename src/content/docs/{workers/wrangler => wrangler/reference}/migration/v1-to-v2/wrangler-legacy/webpack.mdx (85%) create mode 100644 src/content/products/wrangler.yaml create mode 100644 src/icons/wrangler.svg diff --git a/src/content/docs/hyperdrive/examples/prisma-postgres.mdx b/src/content/docs/hyperdrive/examples/prisma-postgres.mdx new file mode 100644 index 000000000000000..cd2a0af375fffeb --- /dev/null +++ b/src/content/docs/hyperdrive/examples/prisma-postgres.mdx @@ -0,0 +1,28 @@ +--- +type: example +summary: Connect Hyperdrive to a Prisma Postgres database. +pcx_content_type: example +title: Connect to Prisma Postgres +sidebar: + order: 9 +description: Connect Hyperdrive to a Prisma Postgres database. +--- + +import { Render } from "~/components"; + +This example shows you how to connect Hyperdrive to a [Prisma](https://www.prisma.io/postgres) Postgres database. Prisma Postgres provides global-first and serverless-ready Postgres databases. + +## 1. Allow Hyperdrive access + +You can connect Hyperdrive to any existing pgEdge database with the default user and password provided by pgEdge. + +### pgEdge dashboard + +To retrieve your connection string from the pgEdge dashboard: + +1. Go to the [**pgEdge dashboard**](https://app.pgedge.com) and select the database you wish to connect to. +2. From the **Connect to your database** section, note down the connection string (starting with `postgres://app@...`) from the **Connection String** text box. + +## 2. Create a database configuration + + diff --git a/src/content/docs/workers/wrangler/api.mdx b/src/content/docs/wrangler/api.mdx similarity index 96% rename from src/content/docs/workers/wrangler/api.mdx rename to src/content/docs/wrangler/api.mdx index 0c9e62edc35bc91..10a0e88efcb09c7 100644 --- a/src/content/docs/workers/wrangler/api.mdx +++ b/src/content/docs/wrangler/api.mdx @@ -1,14 +1,24 @@ --- pcx_content_type: configuration -title: API +title: Programmatic execution sidebar: - order: 2 + order: 4 head: [] description: A set of programmatic APIs that can be integrated with local Cloudflare Workers-related workflows. --- -import { Render, TabItem, Tabs, Type, MetaInfo, WranglerConfig } from "~/components"; +import { + Render, + TabItem, + Tabs, + Type, + MetaInfo, + WranglerConfig, +} from "~/components"; + +Programmatic execution can be useful to automate testing of Workers projects in continuous testing environments. In these scenarios, you need a way +to access the underlying server, emulations or bindings of Cloudflare Workers which are usually present when developing with the Wrangler CLI. Wrangler offers APIs to programmatically interact with your Cloudflare Workers. @@ -340,8 +350,6 @@ The bindings supported by `getPlatformProxy` are: For example, you might have the following file read by `getPlatformProxy`. - - ```toml diff --git a/src/content/docs/workers/wrangler/bundling.mdx b/src/content/docs/wrangler/builds/bundling.mdx similarity index 99% rename from src/content/docs/workers/wrangler/bundling.mdx rename to src/content/docs/wrangler/builds/bundling.mdx index 3a7acb2e080d761..84b3e1cc0c32387 100644 --- a/src/content/docs/workers/wrangler/bundling.mdx +++ b/src/content/docs/wrangler/builds/bundling.mdx @@ -3,6 +3,8 @@ pcx_content_type: configuration title: Bundling head: [] description: Review Wrangler's default bundling. +sidebar: + order: 2 --- By default, Wrangler bundles your Worker code using [`esbuild`](https://esbuild.github.io/). This means that Wrangler has built-in support for importing modules from [npm](https://www.npmjs.com/) defined in your `package.json`. To review the exact code that Wrangler will upload to Cloudflare, run `npx wrangler deploy --dry-run --outdir dist`, which will show your Worker code after Wrangler's bundling. diff --git a/src/content/docs/workers/wrangler/custom-builds.mdx b/src/content/docs/wrangler/builds/custom-builds.mdx similarity index 77% rename from src/content/docs/workers/wrangler/custom-builds.mdx rename to src/content/docs/wrangler/builds/custom-builds.mdx index 73a342f045b2ef3..199b13893b10cc1 100644 --- a/src/content/docs/workers/wrangler/custom-builds.mdx +++ b/src/content/docs/wrangler/builds/custom-builds.mdx @@ -3,10 +3,11 @@ pcx_content_type: configuration title: Custom builds head: [] description: Customize how your code is compiled, before being processed by Wrangler. - +sidebar: + order: 1 --- -import { Render, Type, MetaInfo, WranglerConfig } from "~/components" +import { Render, Type, MetaInfo, WranglerConfig } from "~/components"; Custom builds are a way for you to customize how your code is compiled, before being processed by Wrangler. @@ -19,21 +20,17 @@ With the release of Wrangler v2, it is no longer necessary to use custom builds Custom builds are configured by adding a `[build]` section in your `wrangler.toml / wrangler.json` file, and using the following options for configuring your custom build. +- `command` + - The command used to build your Worker. On Linux and macOS, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used. This command will be run as part of `wrangler dev` and `npx wrangler deploy`. -* `command` - - * The command used to build your Worker. On Linux and macOS, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used. This command will be run as part of `wrangler dev` and `npx wrangler deploy`. - -* `cwd` - - * The directory in which the command is executed. - -* `watch_dir` +- `cwd` - * The directory to watch for changes while using `wrangler dev`. Defaults to the current working directory. + - The directory in which the command is executed. +- `watch_dir` + - The directory to watch for changes while using `wrangler dev`. Defaults to the current working directory. Example: diff --git a/src/content/docs/wrangler/builds/index.mdx b/src/content/docs/wrangler/builds/index.mdx new file mode 100644 index 000000000000000..2ef8046bfcf79d5 --- /dev/null +++ b/src/content/docs/wrangler/builds/index.mdx @@ -0,0 +1,16 @@ +--- +title: Build outputs +pcx_content_type: how-to +head: + - tag: title + content: Build outputs +sidebar: + group: + hideIndex: true + order: 4 +description: Customize how your code is compiled or bundled by Wrangler. +--- + +import { DirectoryListing } from "~/components"; + + diff --git a/src/content/docs/workers/wrangler/commands.mdx b/src/content/docs/wrangler/commands.mdx similarity index 99% rename from src/content/docs/workers/wrangler/commands.mdx rename to src/content/docs/wrangler/commands.mdx index 4d4fe6b7462e5cf..1413a8f83205ac6 100644 --- a/src/content/docs/workers/wrangler/commands.mdx +++ b/src/content/docs/wrangler/commands.mdx @@ -1,13 +1,22 @@ --- pcx_content_type: reference -title: Commands +title: CLI Commands +sidebar: + order: 2 head: - tag: title - content: Commands - Wrangler + content: CLI Commands - Wrangler description: Create, develop, and deploy your Cloudflare Workers with Wrangler commands. --- -import { TabItem, Tabs, Render, Type, MetaInfo, WranglerConfig } from "~/components"; +import { + TabItem, + Tabs, + Render, + Type, + MetaInfo, + WranglerConfig, +} from "~/components"; Wrangler offers a number of commands to manage your Cloudflare Workers. @@ -1841,6 +1850,7 @@ wrangler cert upload certificate-authority --ca-cert [OPTIONS] ``` - `--ca-cert` + - A path to the Certificate Authority (CA) chain certificate to upload. - `--name` diff --git a/src/content/docs/workers/wrangler/configuration.mdx b/src/content/docs/wrangler/configuration/configuration-file.mdx similarity index 99% rename from src/content/docs/workers/wrangler/configuration.mdx rename to src/content/docs/wrangler/configuration/configuration-file.mdx index ca16a75f7f97d61..f5674a5a630f218 100644 --- a/src/content/docs/workers/wrangler/configuration.mdx +++ b/src/content/docs/wrangler/configuration/configuration-file.mdx @@ -1,6 +1,8 @@ --- pcx_content_type: configuration -title: Configuration +title: Configuration file +sidebar: + order: 1 head: - tag: title content: Configuration - Wrangler @@ -412,7 +414,7 @@ watch_dir = "build_watch_dir" You can impose limits on your Worker's behavior at runtime. Limits are only supported for the [Standard Usage Model](/workers/platform/pricing/#example-pricing-standard-usage-model). Limits are only enforced when deployed to Cloudflare's network, not in local development. The CPU limit can be set to a maximum of 30,000 milliseconds (30 seconds). -
+
- `cpu_ms` @@ -631,8 +633,7 @@ deleted_classes = ["DeprecatedClass"] # Array of deleted class names Example: - - + ### Hyperdrive [Hyperdrive](/hyperdrive/) bindings allow you to interact with and query any Postgres database from within a Worker. @@ -1104,7 +1105,7 @@ local_protocol = "http" [Secrets](/workers/configuration/secrets/) are a type of binding that allow you to [attach encrypted text values](/workers/wrangler/commands/#secret) to your Worker. - + ## Module Aliasing @@ -1198,7 +1199,7 @@ upload_source_maps = true ## Workers Sites - + [Workers Sites](/workers/configuration/sites/) allows you to host static websites, or dynamic websites using frameworks like Vue or React, on Workers. diff --git a/src/content/docs/workers/wrangler/environments.mdx b/src/content/docs/wrangler/configuration/environments.mdx similarity index 99% rename from src/content/docs/workers/wrangler/environments.mdx rename to src/content/docs/wrangler/configuration/environments.mdx index aadeae9f43ff6af..7a9c86bf1c6e52e 100644 --- a/src/content/docs/workers/wrangler/environments.mdx +++ b/src/content/docs/wrangler/configuration/environments.mdx @@ -4,6 +4,8 @@ title: Environments head: [] description: Deploy the same Worker application with different configuration for each environment. +sidebar: + order: 3 --- import { WranglerConfig } from "~/components"; @@ -61,8 +63,6 @@ After you have configured your environment, run `npx wrangler deploy` in your Wo Review the following example Wrangler file: - - ```toml @@ -95,8 +95,6 @@ You may assign environment-specific [secrets](/workers/configuration/secrets/) b The following Wrangler file adds two environments, `[env.staging]` and `[env.production]`, to the Wrangler file. If you are deploying to a [Custom Domain](/workers/configuration/routing/custom-domains/) or [route](/workers/configuration/routing/routes/), you must provide a [`route` or `routes` key](/workers/wrangler/configuration/) for each environment. - - ```toml @@ -168,8 +166,6 @@ if (ENVIRONMENT === "staging") { To deploy your code to your `*.workers.dev` subdomain, include `workers_dev = true` in the desired environment. Your Wrangler file may look like this: - - ```toml diff --git a/src/content/docs/wrangler/configuration/index.mdx b/src/content/docs/wrangler/configuration/index.mdx new file mode 100644 index 000000000000000..1156eaa7e2c7691 --- /dev/null +++ b/src/content/docs/wrangler/configuration/index.mdx @@ -0,0 +1,18 @@ +--- +title: Configuration +pcx_content_type: how-to +head: + - tag: title + content: Configuration +sidebar: + group: + hideIndex: true + order: 3 +description: Configure Wrangler to customize the + development and deployment setup for your Worker project and other Developer + Platform products. +--- + +import { DirectoryListing } from "~/components"; + + diff --git a/src/content/docs/workers/wrangler/system-environment-variables.mdx b/src/content/docs/wrangler/configuration/system-environment-variables.mdx similarity index 71% rename from src/content/docs/workers/wrangler/system-environment-variables.mdx rename to src/content/docs/wrangler/configuration/system-environment-variables.mdx index b06f7e938c01dca..1785f0cf47f708a 100644 --- a/src/content/docs/workers/wrangler/system-environment-variables.mdx +++ b/src/content/docs/wrangler/configuration/system-environment-variables.mdx @@ -3,10 +3,11 @@ pcx_content_type: configuration title: System environment variables head: [] description: Local environment variables that can change Wrangler's behavior. - +sidebar: + order: 2 --- -import { Render, Type, MetaInfo } from "~/components" +import { Render, Type, MetaInfo } from "~/components"; System environment variables are local environment variables that can change Wrangler's behavior. There are three ways to set system environment variables: @@ -25,47 +26,41 @@ To set different system environment variables for each environment, create files Wrangler supports the following environment variables: +- `CLOUDFLARE_ACCOUNT_ID` + - The [account ID](/fundamentals/setup/find-account-and-zone-ids/) for the Workers related account. -* `CLOUDFLARE_ACCOUNT_ID` - - * The [account ID](/fundamentals/setup/find-account-and-zone-ids/) for the Workers related account. - -* `CLOUDFLARE_API_TOKEN` - - * The [API token](/fundamentals/api/get-started/create-token/) for your Cloudflare account, can be used for authentication for situations like CI/CD, and other automation. - -* `CLOUDFLARE_API_KEY` - - * The API key for your Cloudflare account, usually used for older authentication method with `CLOUDFLARE_EMAIL=`. - -* `CLOUDFLARE_EMAIL` +- `CLOUDFLARE_API_TOKEN` - * The email address associated with your Cloudflare account, usually used for older authentication method with `CLOUDFLARE_API_KEY=`. + - The [API token](/fundamentals/api/get-started/create-token/) for your Cloudflare account, can be used for authentication for situations like CI/CD, and other automation. -* `WRANGLER_SEND_METRICS` +- `CLOUDFLARE_API_KEY` - * Options for this are `true` and `false`. Defaults to `true`. Controls whether Wrangler can send anonymous usage data to Cloudflare for this project. You can learn more about this in our [data policy](https://github.com/cloudflare/workers-sdk/tree/main/packages/wrangler/telemetry.md). + - The API key for your Cloudflare account, usually used for older authentication method with `CLOUDFLARE_EMAIL=`. -* `WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_` +- `CLOUDFLARE_EMAIL` - * The [local connection string](/hyperdrive/configuration/local-development/) for your database to use in local development with [Hyperdrive](/hyperdrive/). For example, if the binding for your Hyperdrive is named `PROD_DB`, this would be `WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_PROD_DB="postgres://user:password@127.0.0.1:5432/testdb"`. Each Hyperdrive is uniquely distinguished by the binding name. + - The email address associated with your Cloudflare account, usually used for older authentication method with `CLOUDFLARE_API_KEY=`. -* `CLOUDFLARE_API_BASE_URL` +- `WRANGLER_SEND_METRICS` - * The default value is `"https://api.cloudflare.com/client/v4"`. + - Options for this are `true` and `false`. Defaults to `true`. Controls whether Wrangler can send anonymous usage data to Cloudflare for this project. You can learn more about this in our [data policy](https://github.com/cloudflare/workers-sdk/tree/main/packages/wrangler/telemetry.md). -* `WRANGLER_LOG` +- `WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_` - * Options for Logging levels are `"none"`, `"error"`, `"warn"`, `"info"`, `"log"` and `"debug"`. Levels are case-insensitive and default to `"log"`. If an invalid level is specified, Wrangler will fallback to the default. Logs can include requests to Cloudflare's API, any usage data being collected, and more verbose error logs. + - The [local connection string](/hyperdrive/configuration/local-development/) for your database to use in local development with [Hyperdrive](/hyperdrive/). For example, if the binding for your Hyperdrive is named `PROD_DB`, this would be `WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_PROD_DB="postgres://user:password@127.0.0.1:5432/testdb"`. Each Hyperdrive is uniquely distinguished by the binding name. -* `FORCE_COLOR` +- `CLOUDFLARE_API_BASE_URL` - * By setting this to `0`, you can disable Wrangler's colorised output, which makes it easier to read with some terminal setups. For example, `FORCE_COLOR=0`. + - The default value is `"https://api.cloudflare.com/client/v4"`. +- `WRANGLER_LOG` + - Options for Logging levels are `"none"`, `"error"`, `"warn"`, `"info"`, `"log"` and `"debug"`. Levels are case-insensitive and default to `"log"`. If an invalid level is specified, Wrangler will fallback to the default. Logs can include requests to Cloudflare's API, any usage data being collected, and more verbose error logs. +- `FORCE_COLOR` + - By setting this to `0`, you can disable Wrangler's colorised output, which makes it easier to read with some terminal setups. For example, `FORCE_COLOR=0`. ## Example `.env` file @@ -84,8 +79,8 @@ WRANGLER_LOG=debug The following variables are deprecated. Use the new variables listed above to prevent any issues or unwanted messaging. -* `CF_ACCOUNT_ID` -* `CF_API_TOKEN` -* `CF_API_KEY` -* `CF_EMAIL` -* `CF_API_BASE_URL` +- `CF_ACCOUNT_ID` +- `CF_API_TOKEN` +- `CF_API_KEY` +- `CF_EMAIL` +- `CF_API_BASE_URL` diff --git a/src/content/docs/workers/wrangler/index.mdx b/src/content/docs/wrangler/index.mdx similarity index 73% rename from src/content/docs/workers/wrangler/index.mdx rename to src/content/docs/wrangler/index.mdx index 21fb635c7be87cc..e5e5448b6bab863 100644 --- a/src/content/docs/workers/wrangler/index.mdx +++ b/src/content/docs/wrangler/index.mdx @@ -1,11 +1,8 @@ --- title: Wrangler -pcx_content_type: navigation +pcx_content_type: overview sidebar: - order: 15 -head: - - tag: title - content: Wrangler + order: 1 --- import { DirectoryListing } from "~/components"; diff --git a/src/content/docs/workers/wrangler/install-and-update.mdx b/src/content/docs/wrangler/install-and-update.mdx similarity index 97% rename from src/content/docs/workers/wrangler/install-and-update.mdx rename to src/content/docs/wrangler/install-and-update.mdx index c043786cbab6bfd..f51614e59d9eda0 100644 --- a/src/content/docs/workers/wrangler/install-and-update.mdx +++ b/src/content/docs/wrangler/install-and-update.mdx @@ -20,7 +20,7 @@ Wrangler is installed locally into each of your projects. This allows you and yo To install Wrangler within your Worker project, run: - + Since Cloudflare recommends installing Wrangler locally in your project (rather than globally), the way to run Wrangler will depend on your specific setup and package manager. Refer to [How to run Wrangler commands](/workers/wrangler/commands/#how-to-run-wrangler-commands) for more information. diff --git a/src/content/docs/workers/wrangler/deprecations.mdx b/src/content/docs/wrangler/reference/deprecations.mdx similarity index 100% rename from src/content/docs/workers/wrangler/deprecations.mdx rename to src/content/docs/wrangler/reference/deprecations.mdx diff --git a/src/content/docs/wrangler/reference/index.mdx b/src/content/docs/wrangler/reference/index.mdx new file mode 100644 index 000000000000000..e87953508dae9aa --- /dev/null +++ b/src/content/docs/wrangler/reference/index.mdx @@ -0,0 +1,15 @@ +--- +title: Reference +pcx_content_type: how-to +head: + - tag: title + content: Reference +sidebar: + group: + hideIndex: true +description: Additional details about Wrangler usage. +--- + +import { DirectoryListing } from "~/components"; + + diff --git a/src/content/docs/workers/wrangler/migration/index.mdx b/src/content/docs/wrangler/reference/migration/index.mdx similarity index 100% rename from src/content/docs/workers/wrangler/migration/index.mdx rename to src/content/docs/wrangler/reference/migration/index.mdx diff --git a/src/content/docs/workers/wrangler/migration/update-v2-to-v3.mdx b/src/content/docs/wrangler/reference/migration/update-v2-to-v3.mdx similarity index 100% rename from src/content/docs/workers/wrangler/migration/update-v2-to-v3.mdx rename to src/content/docs/wrangler/reference/migration/update-v2-to-v3.mdx diff --git a/src/content/docs/workers/wrangler/migration/v1-to-v2/eject-webpack.mdx b/src/content/docs/wrangler/reference/migration/v1-to-v2/eject-webpack.mdx similarity index 100% rename from src/content/docs/workers/wrangler/migration/v1-to-v2/eject-webpack.mdx rename to src/content/docs/wrangler/reference/migration/v1-to-v2/eject-webpack.mdx diff --git a/src/content/docs/workers/wrangler/migration/v1-to-v2/index.mdx b/src/content/docs/wrangler/reference/migration/v1-to-v2/index.mdx similarity index 100% rename from src/content/docs/workers/wrangler/migration/v1-to-v2/index.mdx rename to src/content/docs/wrangler/reference/migration/v1-to-v2/index.mdx diff --git a/src/content/docs/workers/wrangler/migration/v1-to-v2/update-v1-to-v2.mdx b/src/content/docs/wrangler/reference/migration/v1-to-v2/update-v1-to-v2.mdx similarity index 100% rename from src/content/docs/workers/wrangler/migration/v1-to-v2/update-v1-to-v2.mdx rename to src/content/docs/wrangler/reference/migration/v1-to-v2/update-v1-to-v2.mdx diff --git a/src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/authentication.mdx b/src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/authentication.mdx similarity index 98% rename from src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/authentication.mdx rename to src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/authentication.mdx index 631aaf3f5272156..25c4da42a9d1794 100644 --- a/src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/authentication.mdx +++ b/src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/authentication.mdx @@ -7,7 +7,7 @@ sidebar: import { Render } from "~/components"; - + ## Background diff --git a/src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/commands.mdx b/src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/commands.mdx similarity index 99% rename from src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/commands.mdx rename to src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/commands.mdx index 93a442b23e535b5..9b855036293b5d9 100644 --- a/src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/commands.mdx +++ b/src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/commands.mdx @@ -10,7 +10,7 @@ head: import { Render, Type, MetaInfo, WranglerConfig } from "~/components"; - + Complete list of all commands available for [`wrangler`](https://github.com/cloudflare/wrangler-legacy), the Workers CLI. @@ -540,8 +540,6 @@ Most `kv` commands require you to specify a namespace. A namespace can be specif Most `kv` subcommands also allow you to specify an environment with the optional `--env` flag. This allows you to publish Workers running the same code but with different namespaces. For example, you could use separate staging and production namespaces for KV data in your Wrangler file: - - ```toml diff --git a/src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/configuration.mdx b/src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/configuration.mdx similarity index 77% rename from src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/configuration.mdx rename to src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/configuration.mdx index 68d1d3e6ad49cd5..070bedacb2e6696 100644 --- a/src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/configuration.mdx +++ b/src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/configuration.mdx @@ -6,18 +6,17 @@ sidebar: head: - tag: title content: Configuration - Wrangler v1 (deprecated) - --- -import { Render, WranglerConfig } from "~/components" +import { Render, WranglerConfig } from "~/components"; - + ## Background Your project will need some configuration before you can publish your Worker. Configuration is done through changes to keys and values stored in a Wrangler file located in the root of your project directory. You must manually edit this file to edit your keys and values before you can publish. -*** +--- ## Environments @@ -50,18 +49,16 @@ Environment configuration (optional): the configuration values you specify under Environments allow you to deploy the same project to multiple places under multiple names. These environments are utilized with the `--env` or `-e` flag on the [commands](/workers/wrangler/migration/v1-to-v2/wrangler-legacy/commands/) that are deploying live Workers: -* `build` -* `dev` -* `preview` -* `publish` -* `secret` +- `build` +- `dev` +- `preview` +- `publish` +- `secret` -Some environment properties can be [*inherited*](#keys) from the top-level configuration, but if new values are configured in an environment, they will always override those at the top level. +Some environment properties can be [_inherited_](#keys) from the top-level configuration, but if new values are configured in an environment, they will always override those at the top level. An example of an `[env.name]` configuration looks like this: - - ```toml @@ -101,89 +98,83 @@ preview_id = "999..." To deploy this example Worker to the `helloworld` environment, you would run `wrangler publish --env helloworld`. -*** +--- ## Keys There are three types of keys in a Wrangler file: -* Top level only keys are required to be configured at the top level of your Wrangler file only; multiple environments on the same project must share this key's value. +- Top level only keys are required to be configured at the top level of your Wrangler file only; multiple environments on the same project must share this key's value. -* Inherited keys can be configured at the top level and/or environment. If the key is defined only at the top level, the environment will use the key's value from the top level. If the key is defined in the environment, the environment value will override the top-level value. +- Inherited keys can be configured at the top level and/or environment. If the key is defined only at the top level, the environment will use the key's value from the top level. If the key is defined in the environment, the environment value will override the top-level value. -* Non-inherited keys must be defined for every environment individually. +- Non-inherited keys must be defined for every environment individually. +- `name` inherited required + - The name of your Worker script. If inherited, your environment name will be appended to the top level. -* `name` inherited required +- `type` top level required - * The name of your Worker script. If inherited, your environment name will be appended to the top level. - -* `type` top level required - - * Specifies how `wrangler build` will build your project. There are three options: `javascript`, `webpack`, and `rust`. `javascript` checks for a build command specified in the `[build]` section, `webpack` builds your project using webpack v4, and `rust` compiles the Rust in your project to WebAssembly. + - Specifies how `wrangler build` will build your project. There are three options: `javascript`, `webpack`, and `rust`. `javascript` checks for a build command specified in the `[build]` section, `webpack` builds your project using webpack v4, and `rust` compiles the Rust in your project to WebAssembly. :::note - Cloudflare will continue to support `rust` and `webpack` project types, but recommends using the `javascript` project type and specifying a custom [`build`](#build) section. - ::: -* `account_id` inherited required - - * This is the ID of the account associated with your zone. You might have more than one account, so make sure to use the ID of the account associated with the `zone_id` you provide, if you provide one. It can also be specified through the `CF_ACCOUNT_ID` environment variable. +- `account_id` inherited required -* `zone_id` inherited optional + - This is the ID of the account associated with your zone. You might have more than one account, so make sure to use the ID of the account associated with the `zone_id` you provide, if you provide one. It can also be specified through the `CF_ACCOUNT_ID` environment variable. - * This is the ID of the zone or domain you want to run your Worker on. It can also be specified through the `CF_ZONE_ID` environment variable. This key is optional if you are using only a `*.workers.dev` subdomain. +- `zone_id` inherited optional -* `workers_dev` inherited optional + - This is the ID of the zone or domain you want to run your Worker on. It can also be specified through the `CF_ZONE_ID` environment variable. This key is optional if you are using only a `*.workers.dev` subdomain. - * This is a boolean flag that specifies if your Worker will be deployed to your [`*.workers.dev`](https://workers.dev) subdomain. If omitted, it defaults to false. +- `workers_dev` inherited optional -* `route` not inherited optional + - This is a boolean flag that specifies if your Worker will be deployed to your [`*.workers.dev`](https://workers.dev) subdomain. If omitted, it defaults to false. - * A route, specified by URL pattern, on your zone that you would like to run your Worker on.
`route = "http://example.com/*"`. A `route` OR `routes` key is only required if you are not using a [`*.workers.dev`](https://workers.dev) subdomain. +- `route` not inherited optional -* `routes` not inherited optional + - A route, specified by URL pattern, on your zone that you would like to run your Worker on.
`route = "http://example.com/*"`. A `route` OR `routes` key is only required if you are not using a [`*.workers.dev`](https://workers.dev) subdomain. - * A list of routes you would like to use your Worker on. These follow exactly the same rules a `route`, but you can specify a list of them.
`routes = ["http://example.com/hello", "http://example.com/goodbye"]`. A `route` OR `routes` key is only required if you are not using a `*.workers.dev` subdomain. +- `routes` not inherited optional -* `webpack_config` inherited optional + - A list of routes you would like to use your Worker on. These follow exactly the same rules a `route`, but you can specify a list of them.
`routes = ["http://example.com/hello", "http://example.com/goodbye"]`. A `route` OR `routes` key is only required if you are not using a `*.workers.dev` subdomain. - * This is the path to a custom webpack configuration file for your Worker. You must specify this field to use a custom webpack configuration, otherwise Wrangler will use a default configuration for you. Refer to the [Wrangler webpack page](/workers/wrangler/migration/v1-to-v2/eject-webpack/) for more information. +- `webpack_config` inherited optional -* `vars` not inherited optional + - This is the path to a custom webpack configuration file for your Worker. You must specify this field to use a custom webpack configuration, otherwise Wrangler will use a default configuration for you. Refer to the [Wrangler webpack page](/workers/wrangler/migration/v1-to-v2/eject-webpack/) for more information. - * An object containing text variables that can be directly accessed in a Worker script. +- `vars` not inherited optional -* `kv_namespaces` not inherited optional + - An object containing text variables that can be directly accessed in a Worker script. - * These specify any [Workers KV](#kv_namespaces) Namespaces you want to access from inside your Worker. +- `kv_namespaces` not inherited optional -* `site` inherited optional + - These specify any [Workers KV](#kv_namespaces) Namespaces you want to access from inside your Worker. - * Determines the local folder to upload and serve from a Worker. +- `site` inherited optional -* `dev` not inherited optional + - Determines the local folder to upload and serve from a Worker. - * Arguments for `wrangler dev` that configure local server. +- `dev` not inherited optional -* `triggers` inherited optional + - Arguments for `wrangler dev` that configure local server. - * Configures cron triggers for running a Worker on a schedule. +- `triggers` inherited optional -* `usage_model` inherited optional + - Configures cron triggers for running a Worker on a schedule. - * Specifies the [Usage Model](/workers/platform/pricing/#workers) for your Worker. There are two options - [`bundled`](/workers/platform/limits/#worker-limits) and [`unbound`](/workers/platform/limits/#worker-limits). For newly created Workers, if the Usage Model is omitted it will be set to the [default Usage Model set on the account](https://dash.cloudflare.com/?account=workers/default-usage-model). For existing Workers, if the Usage Model is omitted, it will be set to the Usage Model configured in the dashboard for that Worker. +- `usage_model` inherited optional -* `build` top level optional - - * Configures a custom build step to be run by Wrangler when building your Worker. Refer to the [custom builds documentation](#build) for more details. + - Specifies the [Usage Model](/workers/platform/pricing/#workers) for your Worker. There are two options - [`bundled`](/workers/platform/limits/#worker-limits) and [`unbound`](/workers/platform/limits/#worker-limits). For newly created Workers, if the Usage Model is omitted it will be set to the [default Usage Model set on the account](https://dash.cloudflare.com/?account=workers/default-usage-model). For existing Workers, if the Usage Model is omitted, it will be set to the Usage Model configured in the dashboard for that Worker. +- `build` top level optional + - Configures a custom build step to be run by Wrangler when building your Worker. Refer to the [custom builds documentation](#build) for more details. ### vars @@ -191,8 +182,6 @@ The `vars` key defines a table of [environment variables](/workers/configuration Usage: - - ```toml @@ -216,8 +205,6 @@ console.log(BAR); Alternatively, you can define `vars` using an inline table format. This style should not include any new lines to be considered a valid TOML configuration: - - ```toml @@ -228,20 +215,16 @@ vars = { FOO = "some value", BAR = "some other string" } :::note - Secrets should be handled using the [`wrangler secret`](/workers/wrangler/commands/#secret) command. - ::: -### kv\_namespaces +### kv_namespaces `kv_namespaces` defines a list of KV namespace bindings for your Worker. Usage: - - ```toml @@ -255,8 +238,6 @@ kv_namespaces = [ Alternatively, you can define `kv namespaces` like so: - - ```toml @@ -284,30 +265,24 @@ let value = await FOO.get("keyname"); //=> the "0f2ac...e279" KV namespace ``` +- `binding` required + - The name of the global variable your code will reference. It will be provided as a [KV runtime instance](/kv/api/). -* `binding` required - - * The name of the global variable your code will reference. It will be provided as a [KV runtime instance](/kv/api/). - -* `id` required - - * The ID of the KV namespace that your `binding` should represent. Required for `wrangler publish`. - -* `preview_id` required +- `id` required - * The ID of the KV namespace that your `binding` should represent during `wrangler dev` or `wrangler preview`. Required for `wrangler dev` and `wrangler preview`. + - The ID of the KV namespace that your `binding` should represent. Required for `wrangler publish`. +- `preview_id` required + - The ID of the KV namespace that your `binding` should represent during `wrangler dev` or `wrangler preview`. Required for `wrangler dev` and `wrangler preview`. :::note - Creating your KV namespaces can be handled using Wrangler’s [KV Commands](/workers/wrangler/migration/v1-to-v2/wrangler-legacy/commands/#kv). You can also define your `kv_namespaces` using an [alternative TOML syntax](https://github.com/toml-lang/toml/blob/master/toml.md#user-content-table). - ::: ### site @@ -316,8 +291,6 @@ A [Workers Site](/workers/configuration/sites/start-from-scratch) generated with Usage: - - ```toml @@ -328,25 +301,21 @@ entry-point = "workers-site" +- `bucket` required + - The directory containing your static assets. It must be a path relative to your Wrangler file. Example: `bucket = "./public"` -* `bucket` required - - * The directory containing your static assets. It must be a path relative to your Wrangler file. Example: `bucket = "./public"` +- `entry-point` optional -* `entry-point` optional + - The location of your Worker script. The default location is `workers-site`. Example: `entry-point = "./workers-site"` - * The location of your Worker script. The default location is `workers-site`. Example: `entry-point = "./workers-site"` +- `include` optional -* `include` optional - - * An exclusive list of `.gitignore`-style patterns that match file or directory names from your `bucket` location. Only matched items will be uploaded. Example: `include = ["upload_dir"]` - -* `exclude` optional - - * A list of `.gitignore`-style patterns that match files or directories in your `bucket` that should be excluded from uploads. Example: `exclude = ["ignore_dir"]` + - An exclusive list of `.gitignore`-style patterns that match file or directory names from your `bucket` location. Only matched items will be uploaded. Example: `include = ["upload_dir"]` +- `exclude` optional + - A list of `.gitignore`-style patterns that match files or directories in your `bucket` that should be excluded from uploads. Example: `exclude = ["ignore_dir"]` You can also define your `site` using an [alternative TOML syntax](https://github.com/toml-lang/toml/blob/master/toml.md#user-content-inline-table). @@ -359,8 +328,6 @@ For exceptionally large pages, Workers Sites may not be ideal. There is a 25 MiB If you want to include only a certain set of files or directories in your `bucket`, add an `include` field to your `[site]` section of your Wrangler file: - - ```toml @@ -378,8 +345,6 @@ Wrangler will only upload files or directories matching the patterns in the `inc If you want to exclude files or directories in your `bucket`, add an `exclude` field to your `[site]` section of your Wrangler file: - - ```toml @@ -401,9 +366,9 @@ If you provide both `include` and `exclude` fields, the `include` field will be Wrangler will always ignore: -* `node_modules` -* Hidden files and directories -* Symlinks +- `node_modules` +- Hidden files and directories +- Symlinks #### More about include/exclude patterns @@ -421,8 +386,6 @@ A set of cron triggers used to call a Worker on a schedule. Usage: - - ```toml @@ -432,12 +395,8 @@ crons = ["0 0 * JAN-JUN FRI", "0 0 LW JUL-DEC *"] - - -* `crons` optional - * A set of [cron expressions](https://crontab.guru/), where each expression is a separate schedule to run the Worker on. - - +- `crons` optional + - A set of [cron expressions](https://crontab.guru/), where each expression is a separate schedule to run the Worker on. ### dev @@ -445,8 +404,6 @@ Arguments for `wrangler dev` can be configured here so you do not have to repeat Usage: - - ```toml @@ -457,25 +414,21 @@ local_protocol = "https" +- `ip` optional + - IP address for the local `wrangler dev` server to listen on, defaults to `127.0.0.1`. -* `ip` optional +- `port` optional - * IP address for the local `wrangler dev` server to listen on, defaults to `127.0.0.1`. + - Port for local `wrangler dev` server to listen on, defaults to `8787`. -* `port` optional +- `local_protocol` optional - * Port for local `wrangler dev` server to listen on, defaults to `8787`. - -* `local_protocol` optional - - * Protocol that local `wrangler dev` server listen to requests on, defaults to `http`. - -* `upstream_protocol` optional - - * Protocol that `wrangler dev` forwards requests on, defaults to `https`. + - Protocol that local `wrangler dev` server listen to requests on, defaults to `http`. +- `upstream_protocol` optional + - Protocol that `wrangler dev` forwards requests on, defaults to `https`. ### build @@ -487,14 +440,12 @@ This section is for customizing Workers with the `service-worker` format. These ```js addEventListener("fetch", (event) => { - event.respondWith(new Response("I'm a service Worker!")); + event.respondWith(new Response("I'm a service Worker!")); }); ``` Usage: - - ```toml @@ -509,38 +460,28 @@ format = "service-worker" ##### `[build]` +- `command` optional + - The command used to build your Worker. On Linux and macOS, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used. -* `command` optional - - * The command used to build your Worker. On Linux and macOS, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used. - -* `cwd` optional - - * The working directory for commands, defaults to the project root directory. - -* `watch_dir` optional +- `cwd` optional - * The directory to watch for changes while using `wrangler dev`, defaults to the `src` relative to the project root directory. + - The working directory for commands, defaults to the project root directory. +- `watch_dir` optional + - The directory to watch for changes while using `wrangler dev`, defaults to the `src` relative to the project root directory. ##### `[build.upload]` +- `format` required - -* `format` required - - * The format of the Worker script, must be `"service-worker"`. - - + - The format of the Worker script, must be `"service-worker"`. :::note - Ensure the `main` field in your `package.json` references the Worker you want to publish. - ::: #### Modules @@ -553,10 +494,8 @@ Modules receive all bindings (KV Namespaces, Environment Variables, and Secrets) :::note - Refer to the [`fetch()` handler documentation](/workers/runtime-apis/handlers/fetch) to learn more about the differences between the Service Worker and Module worker formats. - ::: An uploaded module may `import` other uploaded ES Modules. If using the CommonJS format, you may `require` other uploaded CommonJS modules. @@ -565,21 +504,19 @@ An uploaded module may `import` other uploaded ES Modules. If using the CommonJS import html from "./index.html"; export default { - // * request is the same as `event.request` from the service worker format - // * waitUntil() and passThroughOnException() are accessible from `ctx` instead of `event` from the service worker format - // * env is where bindings like KV namespaces, Durable Object namespaces, Config variables, and Secrets - // are exposed, instead of them being placed in global scope. - async fetch(request, env, ctx) { - const headers = { "Content-Type": "text/html;charset=UTF-8" }; - return new Response(html, { headers }); - }, + // * request is the same as `event.request` from the service worker format + // * waitUntil() and passThroughOnException() are accessible from `ctx` instead of `event` from the service worker format + // * env is where bindings like KV namespaces, Durable Object namespaces, Config variables, and Secrets + // are exposed, instead of them being placed in global scope. + async fetch(request, env, ctx) { + const headers = { "Content-Type": "text/html;charset=UTF-8" }; + return new Response(html, { headers }); + }, }; ``` To create a Workers project using Wrangler and Modules, add a `[build]` section: - - ```toml @@ -595,56 +532,46 @@ main = "./worker.mjs" ##### `[build]` +- `command` optional + - The command used to build your Worker. On Linux and macOS system, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used. -* `command` optional +- `cwd` optional - * The command used to build your Worker. On Linux and macOS system, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used. - -* `cwd` optional - - * The working directory for commands, defaults to the project root directory. - -* `watch_dir` optional - - * The directory to watch for changes while using `wrangler dev`, defaults to the `src` relative to the project root directory. + - The working directory for commands, defaults to the project root directory. +- `watch_dir` optional + - The directory to watch for changes while using `wrangler dev`, defaults to the `src` relative to the project root directory. ##### `[build.upload]` +- `format` required + - The format of the Workers script, must be `"modules"`. -* `format` required - - * The format of the Workers script, must be `"modules"`. +- `dir` optional -* `dir` optional + - The directory you wish to upload your modules from, defaults to the `dist` relative to the project root directory. - * The directory you wish to upload your modules from, defaults to the `dist` relative to the project root directory. +- `main` required -* `main` required - - * The relative path of the main module from `dir`, including the `./` prefix. The main module must be an ES module. For projects with a build script, this usually refers to the output of your JavaScript bundler. + - The relative path of the main module from `dir`, including the `./` prefix. The main module must be an ES module. For projects with a build script, this usually refers to the output of your JavaScript bundler. :::note - If your project is written using CommonJS modules, you will need to re-export your handlers and Durable Object classes using an ES module shim. Refer to the [modules-webpack-commonjs](https://github.com/cloudflare/modules-webpack-commonjs) template as an example. - ::: -* `rules` optional +- `rules` optional - * An ordered list of rules that define which modules to import, and what type to import them as. + - An ordered list of rules that define which modules to import, and what type to import them as. You will need to specify rules to use Text, Data, and CompiledWasm modules, or when you wish to have a `.js` file be treated as an `ESModule` instead of `CommonJS`. Defaults: - - ```toml @@ -666,28 +593,24 @@ globs = ["**/*.js", "**/*.cjs"] -* `type` required +- `type` required - * The module type, see the table below for acceptable options: + - The module type, see the table below for acceptable options: -* `globs` required +- `globs` required - * UNIX-style [glob rules](https://docs.rs/globset/0.4.6/globset/#syntax) that are used to determine the module type to use for a given file in `dir`. Globs are matched against the module's relative path from `build.upload.dir` without the `./` prefix. Rules are evaluated in order, starting at the top. + - UNIX-style [glob rules](https://docs.rs/globset/0.4.6/globset/#syntax) that are used to determine the module type to use for a given file in `dir`. Globs are matched against the module's relative path from `build.upload.dir` without the `./` prefix. Rules are evaluated in order, starting at the top. -* `fallthrough` optional +- `fallthrough` optional - * This option allows further rules for this module type to be considered if set to true. If not specified or set to false, further rules for this module type will be ignored. + - This option allows further rules for this module type to be considered if set to true. If not specified or set to false, further rules for this module type will be ignored. - - -*** +--- ## Example To illustrate how these levels are applied, here is a Wrangler file using multiple environments: - - ```toml diff --git a/src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/index.mdx b/src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/index.mdx similarity index 63% rename from src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/index.mdx rename to src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/index.mdx index 944d69832e5395d..40bbf6e51bfa2a4 100644 --- a/src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/index.mdx +++ b/src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/index.mdx @@ -4,13 +4,12 @@ pcx_content_type: navigation head: - tag: title content: Wrangler v1 (legacy) - --- -import { DirectoryListing, Render } from "~/components" +import { DirectoryListing, Render } from "~/components"; The following documentation applied to Wrangler v1 usage. - + diff --git a/src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/install-update.mdx b/src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/install-update.mdx similarity index 97% rename from src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/install-update.mdx rename to src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/install-update.mdx index 9b2370a4542722f..d492691ef406abb 100644 --- a/src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/install-update.mdx +++ b/src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/install-update.mdx @@ -7,7 +7,7 @@ sidebar: import { Render } from "~/components"; - + ## Install diff --git a/src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/webpack.mdx b/src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/webpack.mdx similarity index 85% rename from src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/webpack.mdx rename to src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/webpack.mdx index 7d9ff2c84345c02..7a854dbcde4bb0d 100644 --- a/src/content/docs/workers/wrangler/migration/v1-to-v2/wrangler-legacy/webpack.mdx +++ b/src/content/docs/wrangler/reference/migration/v1-to-v2/wrangler-legacy/webpack.mdx @@ -3,23 +3,20 @@ pcx_content_type: configuration title: Webpack sidebar: order: 5 - --- -import { Render, WranglerConfig } from "~/components" +import { Render, WranglerConfig } from "~/components"; - + Wrangler allows you to develop modern ES6 applications with support for modules. This support is possible because of Wrangler's [webpack](https://webpack.js.org/) integration. This document describes how Wrangler uses webpack to build your Workers and how you can bring your own configuration. :::note[Configuration and webpack version] - Wrangler includes `webpack@4`. If you want to use `webpack@5`, or another bundler like esbuild or Rollup, you must set up [custom builds](/workers/wrangler/migration/v1-to-v2/wrangler-legacy/configuration/#build) in your Wrangler file. You must set `type = "webpack"` in your Wrangler file to use Wrangler's webpack integration. If you are encountering warnings about specifying `webpack_config`, refer to [backwards compatibility](#backwards-compatibility). - ::: ## Sensible defaults @@ -28,8 +25,8 @@ This is the default webpack configuration that Wrangler uses to build your Worke ```js module.exports = { - target: "webworker", - entry: "./index.js", // inferred from "main" in package.json + target: "webworker", + entry: "./index.js", // inferred from "main" in package.json }; ``` @@ -45,9 +42,9 @@ You can tell Wrangler to use a custom webpack configuration file by setting `web ```js module.exports = { - target: 'webworker', - entry: './index.js', - mode: 'production', + target: "webworker", + entry: "./index.js", + mode: "production", }; ``` @@ -67,8 +64,6 @@ webpack_config = "webpack.config.js" It is possible to use different webpack configuration files within different [Wrangler environments](/workers/wrangler/environments/). For example, the `"webpack.development.js"` configuration file is used during `wrangler dev` for development, but other, more production-ready configurations are used when building for the staging or production environments: - - ```toml @@ -91,18 +86,18 @@ webpack_config = "webpack.production.js" ```js module.exports = { - target: 'webworker', - devtool: 'cheap-module-source-map', // avoid "eval": Workers environment doesn’t allow it - entry: './index.js', - mode: 'development', + target: "webworker", + devtool: "cheap-module-source-map", // avoid "eval": Workers environment doesn’t allow it + entry: "./index.js", + mode: "development", }; ``` ```js module.exports = { - target: 'webworker', - entry: './index.js', - mode: 'production', + target: "webworker", + entry: "./index.js", + mode: "production", }; ``` @@ -127,10 +122,10 @@ The corresponding `webpack.config.js` file should look like this: ```js module.exports = { - context: __dirname, - target: 'webworker', - entry: './index.js', - mode: 'production', + context: __dirname, + target: "webworker", + entry: "./index.js", + mode: "production", }; ``` @@ -143,17 +138,17 @@ For example, you may want to replace the `URL` global class with the `url-polyfi ### Example with webpack plugin ```js null {1,7,8,9,10,11} -const webpack = require('webpack'); +const webpack = require("webpack"); module.exports = { - target: 'webworker', - entry: './index.js', - mode: 'production', - plugins: [ - new webpack.ProvidePlugin({ - URL: 'url-polyfill', - }), - ], + target: "webworker", + entry: "./index.js", + mode: "production", + plugins: [ + new webpack.ProvidePlugin({ + URL: "url-polyfill", + }), + ], }; ``` diff --git a/src/content/products/wrangler.yaml b/src/content/products/wrangler.yaml new file mode 100644 index 000000000000000..9928ee3de605d75 --- /dev/null +++ b/src/content/products/wrangler.yaml @@ -0,0 +1,28 @@ +name: Wrangler + +product: + title: Wrangler + url: /wrangler/ + group: Developer platform + preview_tryout: true + +meta: + title: Cloudflare Wrangler + description: Use Wrangler to manage your Cloudflare developer platform resources and run Cloudflare Workers projects locally + author: "@cloudflare" + +resources: + community: https://community.cloudflare.com/c/developers/workers/40 + dashboard_link: https://dash.cloudflare.com/?to=/:account/workers + learning_center: https://www.cloudflare.com/learning/serverless/what-is-serverless/ + discord: https://discord.com/invite/cloudflaredev + +externals: + - title: Workers home + url: https://workers.cloudflare.com + - title: Playground + url: https://workers.cloudflare.com/playground + - title: Pricing + url: https://workers.cloudflare.com/#plans + - title: Discord + url: https://discord.cloudflare.com diff --git a/src/icons/wrangler.svg b/src/icons/wrangler.svg new file mode 100644 index 000000000000000..8bd10c77fe52bcf --- /dev/null +++ b/src/icons/wrangler.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/util/sidebar.ts b/src/util/sidebar.ts index 1d8cbbde7272d0c..f0c07b345049076 100644 --- a/src/util/sidebar.ts +++ b/src/util/sidebar.ts @@ -16,8 +16,9 @@ const sidebars = new Map(); export async function getSidebar(context: AstroGlobal) { const pathname = context.url.pathname; + console.log(pathname); const segments = pathname.split("/").slice(1, -1); - + console.log(segments); const product = segments.at(0); if (!product) {