diff --git a/src/content/docs/containers/get-started.mdx b/src/content/docs/containers/get-started.mdx index 7dfbf6311d6..023d098aa89 100644 --- a/src/content/docs/containers/get-started.mdx +++ b/src/content/docs/containers/get-started.mdx @@ -29,6 +29,10 @@ In this guide, we will build and push a container image alongside your Worker co ## Deploy your first Container +If you already have a project with a `Dockerfile` or `Containerfile`, Wrangler can generate a singleton Containers Worker for you: + + + Run the following command to create and deploy a new Worker with a container, from the starter template: @@ -78,11 +106,13 @@ A new Wrangler configuration file is created with settings appropriate for your -The exact configuration varies based on your framework. +The exact configuration varies based on your framework or project type. + +For Express.js apps, `wrangler.jsonc` sets `main` to the generated Worker wrapper and adds the `nodejs_compat` compatibility flag. For Containers, `wrangler.jsonc` includes the generated Container, Durable Object binding, and migration configuration. ### `package.json` -New scripts are added to your `package.json`: +New dependencies and scripts may be added to your `package.json`. For example, Dockerfile-backed Containers add `@cloudflare/containers`. For a framework project, scripts can look like: ```json { @@ -118,20 +148,76 @@ _routes.json ### Deploy with automatic configuration -To deploy an existing project, run [`wrangler deploy`](/workers/wrangler/commands/general/#deploy) in your project directory: +To deploy an existing project, run [`wrangler deploy`](/workers/wrangler/commands/workers/#deploy) in your project directory: -Wrangler will detect your framework, show the configuration it will apply, and prompt you to confirm before making changes and deploying. +Wrangler will detect your framework or project type, show the configuration it will apply, and prompt you to confirm before making changes and deploying. + +### Deploy a specific target + +To deploy an explicit target, pass the target path to [`wrangler deploy`](/workers/wrangler/commands/workers/#deploy): + + + +You can use explicit targets for Express.js server entrypoints, single HTML files, static asset directories, static Vite app directories, Dockerfiles, and Containerfiles. + +To deploy a standalone HTML file without creating a `wrangler.jsonc` file, pass the HTML file directly: + +"} +/> + +If you deploy a named HTML file, Wrangler serves it at `/` and at its original filename. For example, `wrangler deploy landing.html` serves the same file at `/` and `/landing.html`. + +To deploy an Express.js app, pass the server entrypoint directly: + +"} +/> + +Wrangler generates a Worker wrapper in `src/worker.js` or `src/worker.ts`. It uses Node.js compatibility and the detected HTTP port. If Wrangler cannot detect a port, it uses port `3000`. + +Wrangler refuses to overwrite an existing generated entrypoint, such as `src/worker.js` or `src/worker.ts`. Move or remove that file before trying again. + +For Dockerfile-backed Containers, pass `Dockerfile` or `Containerfile` as the deploy target: + + + +After Wrangler configures a Containers project, use `wrangler deploy` for future deploys. Do not continue passing `Dockerfile` or `Containerfile` as the deploy target. + +For explicit static directories, pass the directory directly: + + + +Wrangler deploys the target directory without writing `wrangler.jsonc`. + +To deploy a static Vite app directory, pass the app directory with `--experimental-auto-config-static-assets`: + + + +For a static Vite app directory, Wrangler runs the build command, verifies that `dist/index.html` exists, and deploys `dist`. If `dist/index.html` is missing after the build, check your build command or deploy the output directory explicitly with `--assets`. + +When Wrangler deploys assets, it ignores `.wrangler/**`. If `WRANGLER_OUTPUT_FILE_PATH` points inside the assets directory, Wrangler warns and ignores that output file. ### Configure without deploying -To configure your project without deploying, use [`wrangler setup`](/workers/wrangler/commands/general/#setup): +To configure your project without deploying, use [`wrangler setup`](/workers/wrangler/commands/workers/#setup): This is useful when you want to review the generated configuration before deploying. +For Dockerfile-backed Containers, run this command from the project root that contains the `Dockerfile` or `Containerfile`. + ### Preview changes with dry run To see what changes would be made without actually modifying any files: @@ -142,11 +228,19 @@ This outputs a summary of the configuration that would be generated. ## Non-interactive mode -To skip the confirmation prompts, use the [`--yes` flag](/workers/wrangler/commands/general/#deploy): +To skip the confirmation prompts, use the [`--yes` flag](/workers/wrangler/commands/workers/#deploy): -This applies the configuration automatically using sensible defaults. This is useful in CI/CD environments or when you want to accept the detected settings without reviewing them. +This applies the configuration automatically using detected defaults. This is useful in CI/CD environments or when you want to accept the detected settings without reviewing them. + +Dockerfile-backed Containers require an explicit target or `wrangler setup --yes` for non-interactive configuration. Use one of the following commands: + + + + + +In CI, pass the Dockerfile or Containerfile target explicitly, or use `wrangler setup --yes`. Bare Dockerfile detection is not used in non-interactive sessions. ## Importing a repository from the dashboard @@ -187,8 +281,40 @@ If your framework is not detected, ensure your `package.json` includes the frame If a Wrangler configuration file already exists, automatic configuration will not run. To reconfigure your project, delete the existing configuration file and run `wrangler deploy` or `wrangler setup` again. +For configured Containers projects, run `wrangler deploy` to deploy the Worker and configured container together. Running `wrangler deploy Dockerfile` or `wrangler deploy Containerfile` treats the file as a Worker entrypoint and is not supported. + +### Generated file already exists + +Wrangler will not overwrite files it generates for adapter-based configuration. If you see an error such as `Refusing to overwrite generated file src/worker.js`, move or remove the existing file and try again. + +### Static app output missing + +For static Vite app directories, Wrangler expects the build command to create `dist/index.html`. If the file is missing after build, check your build command or deploy the output directory explicitly with `--assets`. + +### Dockerfile port detection + +For Dockerfile-backed Containers, Wrangler detects the Container port from your Dockerfile. If the Dockerfile has one `EXPOSE` value, Wrangler uses it. If the Dockerfile does not have exactly one `EXPOSE` value but `ENV PORT=` is set, Wrangler uses that value. If there are multiple `EXPOSE` values and no `ENV PORT=`, Wrangler uses the first `EXPOSE` value and warns you. If no port is detected, Wrangler uses port `80` and warns you. Update the generated Worker if your container listens on a different port. + +### Container readiness + +After Wrangler creates or modifies a container application, the application can take a few minutes to become ready. During provisioning, requests may return `503` or `500`. Wrangler prints a status command after deploy. + +To list container applications with health details, run: + + + +To inspect instance placement and status details, run: + + --json"} +/> + +Use the application ID from `wrangler containers list --json`. If instances are stopped or unhealthy, non-JSON output suggests the JSON command for more details. + ### Workspaces -Support for monorepos and npm/yarn/pnpm workspaces is currently limited. Wrangler analyzes the project directory where you run the command, but does not detect dependencies installed at the workspace root. This can cause framework detection to fail if the framework is listed as a dependency in the workspace's root `package.json` rather than in the individual project's `package.json`. +Support for monorepos and npm/yarn/pnpm workspaces is limited. Wrangler analyzes the project directory where you run the command, but does not detect dependencies installed at the workspace root. This can cause framework detection to fail if the framework is listed as a dependency in the root `package.json` for the workspace rather than in the individual project `package.json`. If you encounter issues, report them in the [Wrangler GitHub repository](https://github.com/cloudflare/workers-sdk/issues/new/choose). diff --git a/src/content/docs/workers/framework-guides/web-apps/react.mdx b/src/content/docs/workers/framework-guides/web-apps/react.mdx index 169d6985855..fac52ed2441 100644 --- a/src/content/docs/workers/framework-guides/web-apps/react.mdx +++ b/src/content/docs/workers/framework-guides/web-apps/react.mdx @@ -33,6 +33,8 @@ import { [![Deploy to Workers](https://deploy.workers.cloudflare.com/button)](https://dash.cloudflare.com/?to=/:account/workers-and-pages/create/deploy-to-workers&repository=https://github.com/cloudflare/templates/tree/main/vite-react-template) +If you already have a React app built with Vite and do not need a Worker API, Wrangler can deploy it with `--experimental-auto-config-static-assets`. For more information, refer to [Deploy an existing project](/workers/framework-guides/automatic-configuration/#deploy-a-specific-target). + ## What is React? [React](https://react.dev/) is a framework for building user interfaces. It allows you to create reusable UI components and manage the state of your application efficiently. You can use React to build a single-page application (SPA), and combine it with a backend API running on Cloudflare Workers to create a full-stack application. diff --git a/src/content/docs/workers/framework-guides/web-apps/vue.mdx b/src/content/docs/workers/framework-guides/web-apps/vue.mdx index e3f18d090e9..4c68766b3b3 100644 --- a/src/content/docs/workers/framework-guides/web-apps/vue.mdx +++ b/src/content/docs/workers/framework-guides/web-apps/vue.mdx @@ -22,6 +22,8 @@ import { In this guide, you will create a new [Vue](https://vuejs.org/) application and deploy to Cloudflare Workers (with the new [Workers Assets](/workers/static-assets/)). +If you already have a Vue app built with Vite and do not need a Worker API, Wrangler can deploy it with `--experimental-auto-config-static-assets`. For more information, refer to [Deploy an existing project](/workers/framework-guides/automatic-configuration/#deploy-a-specific-target). + ## 1. Set up a new project Use the [`create-cloudflare`](https://www.npmjs.com/package/create-cloudflare) CLI (C3) to set up a new project. C3 will create a new project directory, use code from the official Vue template, and provide the option to deploy instantly. @@ -34,30 +36,34 @@ To use `create-cloudflare` to create a new Vue project with Workers Assets, run args="my-vue-app --framework=vue" /> -
- Below is a simplified file tree of the project. - - - my-vue-app - - src/ - - App.vue - - server/ - - index.ts - - index.html - - vite.config.ts - - wrangler.jsonc - - - `wrangler.jsonc` is your [Wrangler configuration file](/workers/wrangler/configuration/). - In this file: - - `main` points to `server/index.ts`. This is your Worker, which is going to act as your backend API. - - `assets.not_found_handling` is set to `single-page-application`, which means that routes that are handled by your Vue SPA do not go to the Worker, and are thus free. - - If you want to add bindings to resources on Cloudflare's developer platform, you configure them here. Read more about [bindings](/workers/runtime-apis/bindings/). - - `vite.config.ts` is set up to use the [Cloudflare Vite plugin](/workers/vite-plugin/). This runs your Worker in the Cloudflare Workers runtime, ensuring your local development environment is as close to production as possible. - - `server/index.ts` is your backend API, which contains a single endpoint, `/api/`, that returns a text response. - At `src/App.vue`, your Vue app calls this endpoint to get a message back and displays this. -
+
+ +Below is a simplified file tree of the project. + + + +- my-vue-app + - src/ + - App.vue + - server/ + - index.ts + - index.html + - vite.config.ts + - wrangler.jsonc + + + +`wrangler.jsonc` is your [Wrangler configuration file](/workers/wrangler/configuration/). In this file: + +- `main` points to `server/index.ts`. This is your Worker, which acts as your backend API. +- `assets.not_found_handling` is set to `single-page-application`. Routes handled by your Vue SPA do not go to the Worker, and are free. +- Bindings to resources on Cloudflare's developer platform are configured here. For more information, refer to [Bindings](/workers/runtime-apis/bindings/). + +`vite.config.ts` is set up to use the [Cloudflare Vite plugin](/workers/vite-plugin/). This runs your Worker in the Cloudflare Workers runtime, ensuring your local development environment is as close to production as possible. + +`server/index.ts` is your backend API, which contains a single endpoint, `/api/`, that returns a text response. At `src/App.vue`, your Vue app calls this endpoint to get a message back and displays this. + +
## 2. Develop locally with the [Cloudflare Vite plugin](/workers/vite-plugin/) diff --git a/src/content/docs/workers/runtime-apis/nodejs/http.mdx b/src/content/docs/workers/runtime-apis/nodejs/http.mdx index 703b5a2a71b..41fce395bf5 100644 --- a/src/content/docs/workers/runtime-apis/nodejs/http.mdx +++ b/src/content/docs/workers/runtime-apis/nodejs/http.mdx @@ -249,6 +249,8 @@ export default httpServerHandler({ port: 8080 }); The `httpServerHandler` function integrates Node.js HTTP servers with the Cloudflare Workers request model. It supports two API patterns: +If you already have an Express-style Node HTTP server, Wrangler can generate the Worker wrapper and Node.js compatibility configuration for you. Static assets and WebSocket routes may require manual migration. For more information, refer to [Deploy an existing project](/workers/framework-guides/automatic-configuration/#deploy-a-specific-target). + ```js import http from "node:http"; import { httpServerHandler } from "cloudflare:node"; diff --git a/src/content/docs/workers/static-assets/binding.mdx b/src/content/docs/workers/static-assets/binding.mdx index 42452e45ac8..3d43f1b1643 100644 --- a/src/content/docs/workers/static-assets/binding.mdx +++ b/src/content/docs/workers/static-assets/binding.mdx @@ -22,7 +22,9 @@ import { WranglerConfig, } from "~/components"; -Configuring a Worker with assets requires specifying a [directory](/workers/static-assets/binding/#directory) and, optionally, an [assets binding](/workers/static-assets/binding/), in your Worker's Wrangler file. The [assets binding](/workers/static-assets/binding/) allows you to dynamically fetch assets from within your Worker script (e.g. `env.ASSETS.fetch()`), similarly to how you might with a make a `fetch()` call with a [Service binding](/workers/runtime-apis/bindings/service-bindings/http/). +When you use persistent Worker configuration, configure assets by specifying a [directory](/workers/static-assets/binding/#directory) and, optionally, an [assets binding](/workers/static-assets/binding/), in your Worker's Wrangler file. The [assets binding](/workers/static-assets/binding/) allows you to dynamically fetch assets from within your Worker script, for example `env.ASSETS.fetch()`, similar to making a `fetch()` call with a [Service binding](/workers/runtime-apis/bindings/service-bindings/http/). + +Wrangler can also deploy some static asset targets without creating a persistent Wrangler configuration file. Static directories that contain `index.html` deploy without a flag. Static Vite apps require `--experimental-auto-config-static-assets`. For more information, refer to [Deploy an existing project](/workers/framework-guides/automatic-configuration/#deploy-a-specific-target). Only one collection of static assets can be configured in each Worker. diff --git a/src/content/docs/workers/static-assets/get-started.mdx b/src/content/docs/workers/static-assets/get-started.mdx index 64d47cdc9e3..698e5e70538 100644 --- a/src/content/docs/workers/static-assets/get-started.mdx +++ b/src/content/docs/workers/static-assets/get-started.mdx @@ -29,6 +29,32 @@ Alternatively, you may prefer to build your website from scratch if: This guide will instruct you through setting up and deploying a static site or a full-stack application without a framework on Workers. +## Deploy existing static assets + +If you already have a standalone HTML file, Wrangler can deploy it directly. Pass the file to `wrangler deploy`: + +"} +/> + +For an existing static directory, pass the directory directly: + + + +For a static Vite app directory, pass the directory with `--experimental-auto-config-static-assets`: + + + +For a static Vite app directory, Wrangler runs the build command and deploys `dist`. The build output must contain `dist/index.html`. + +For more information, refer to [Deploy an existing project](/workers/framework-guides/automatic-configuration/). + ## Deploy a static site This guide will instruct you through setting up and deploying a static site on Workers. diff --git a/src/content/docs/workers/static-assets/index.mdx b/src/content/docs/workers/static-assets/index.mdx index a772d4bde2f..0cbca0777ba 100644 --- a/src/content/docs/workers/static-assets/index.mdx +++ b/src/content/docs/workers/static-assets/index.mdx @@ -58,7 +58,9 @@ Learn more about supported frameworks on Workers. When you deploy your project, Cloudflare deploys both your Worker code and your static assets in a single operation. This deployment operates as a tightly integrated "unit" running across Cloudflare's network, combining static file hosting, custom logic, and global caching. -The **assets directory** specified in your [Wrangler configuration file](/workers/wrangler/configuration/#assets) is central to this design. During deployment, Wrangler automatically uploads the files from this directory to Cloudflare's infrastructure. Once deployed, requests for these assets are routed efficiently to locations closest to your users. +For projects with persistent configuration, the **assets directory** specified in your [Wrangler configuration file](/workers/wrangler/configuration/#assets) is central to this design. During deployment, Wrangler automatically uploads the files from this directory to Cloudflare's infrastructure. Once deployed, requests for these assets are routed efficiently to locations closest to your users. + +If you already have a standalone HTML file or a static directory that contains `index.html`, Wrangler can deploy it without creating a Wrangler configuration file. Static Vite apps require `--experimental-auto-config-static-assets`. For more information, refer to [Deploy an existing project](/workers/framework-guides/automatic-configuration/#deploy-a-specific-target). diff --git a/src/content/docs/workers/static-assets/migration-guides/migrate-from-pages.mdx b/src/content/docs/workers/static-assets/migration-guides/migrate-from-pages.mdx index 153b233bbcf..f7d7f8ab44d 100644 --- a/src/content/docs/workers/static-assets/migration-guides/migrate-from-pages.mdx +++ b/src/content/docs/workers/static-assets/migration-guides/migrate-from-pages.mdx @@ -32,6 +32,12 @@ Unlike Pages, Workers has a distinctly broader set of features available to it, Migrating from Cloudflare Pages to Cloudflare Workers is often a straightforward process. The following are some of the most common steps you will need to take to migrate your project. +For supported frameworks and project types, Wrangler can [configure or deploy your project automatically](/workers/framework-guides/automatic-configuration/). From your project root, run: + + + +If Wrangler detects your project, review the generated configuration before deploying. Continue with the manual migration steps if you need to migrate Pages Functions, adjust static asset routing, or configure an unsupported project. + ### Frameworks If your Pages project uses [a popular framework](/workers/framework-guides/), most frameworks already have adapters available for Cloudflare Workers. Switch out any Pages-specific adapters for the Workers equivalent and follow any guidance that they provide. @@ -321,27 +327,25 @@ If you are using Pages' built-in CI/CD system, you can swap this for Workers Bui Pages automatically creates a preview environment for each project, and can be independently configured. -To get a similar experience in Workers, you must: - -1. Ensure [preview URLs](/workers/versions-and-deployments/preview-urls/) are enabled (they are on by default). +To get a similar experience in Workers, ensure [preview URLs](/workers/versions-and-deployments/preview-urls/) are enabled. They are on by default. - + - ```json - { - "name": "my-worker", - "compatibility_date": "$today", - "main": "./worker/index.ts", - "assets": { - "directory": "./dist/client/" - }, - "preview_urls": true - } - ``` +```json +{ + "name": "my-worker", + "compatibility_date": "$today", + "main": "./worker/index.ts", + "assets": { + "directory": "./dist/client/" + }, + "preview_urls": true +} +``` - + -1. [Enable non-production branch builds](/workers/ci-cd/builds/build-branches/#configure-non-production-branch-builds) in Workers Builds. +Then, [enable non-production branch builds](/workers/ci-cd/builds/build-branches/#configure-non-production-branch-builds) in Workers Builds. Optionally, you can also [protect these preview URLs with Cloudflare Access](/workers/versions-and-deployments/preview-urls/#manage-access-to-preview-urls). @@ -412,11 +416,11 @@ This compatibility matrix compares the features of Workers and Pages. Unless oth | ----------------------------------------------------------------------------------------------------------- | ------- | ------- | | **Writing, Testing, and Deploying Code** | | | | [Cloudflare Vite plugin](/workers/vite-plugin/) | ✅ | ❌ | -| [Rollbacks](/workers/versions-and-deployments/rollbacks/) | ✅ | ✅ | -| [Gradual Deployments](/workers/versions-and-deployments/) | ✅ | ❌ | +| [Rollbacks](/workers/versions-and-deployments/rollbacks/) | ✅ | ✅ | +| [Gradual Deployments](/workers/versions-and-deployments/) | ✅ | ❌ | | [Preview URLs](/workers/versions-and-deployments/preview-urls/) | ✅ | ✅ | | [Testing tools](/workers/testing) | ✅ | ✅ | -| [Local Development](/workers/local-development/) | ✅ | ✅ | +| [Local Development](/workers/local-development/) | ✅ | ✅ | | [Remote Development (`--remote`)](/workers/wrangler/commands/) | ✅ | ❌ | | [Quick Editor in Dashboard](https://blog.cloudflare.com/improved-quick-edit) | ✅ | ❌ | | **Static Assets** | | | diff --git a/src/content/docs/workers/static-assets/migration-guides/netlify-to-workers.mdx b/src/content/docs/workers/static-assets/migration-guides/netlify-to-workers.mdx index 149ac21e506..4e825f2ff47 100644 --- a/src/content/docs/workers/static-assets/migration-guides/netlify-to-workers.mdx +++ b/src/content/docs/workers/static-assets/migration-guides/netlify-to-workers.mdx @@ -4,12 +4,12 @@ difficulty: Beginner pcx_content_type: tutorial title: Migrate from Netlify to Workers description: >- - Migrate your Netlify application to Cloudflare Workers. You should already have an existing project deployed on Netlified that you would like to host on Workers. + Migrate your Netlify application to Cloudflare Workers. You should already have an existing project deployed on Netlify that you would like to host on Workers. products: - workers --- -import { WranglerConfig } from "~/components"; +import { PackageManagers, WranglerConfig } from "~/components"; In this tutorial, you will learn how to migrate your Netlify application to Cloudflare Workers. @@ -19,6 +19,12 @@ You should already have an existing project deployed on Netlify that you would l Some frameworks like Next.js, Astro with on demand rendering, and others have specific guides for migrating to Cloudflare Workers. Refer to our [framework guides](/workers/framework-guides/) for more information. If your framework has a **Deploy an existing project on Workers** guide, follow that guide for specific instructions. Otherwise, continue with the steps below. +For supported frameworks and project types, Wrangler can [configure or deploy your project automatically](/workers/framework-guides/automatic-configuration/). From your project root, run: + + + +If Wrangler detects your project, confirm the generated settings. If Wrangler cannot detect your project or you need to adjust routing behavior, continue with the manual migration steps. + ## Find your build command and build directory To move your application to Cloudflare Workers, you will need to know your build command and build directory. Cloudflare Workers will use this information to build and deploy your application. We will cover how to find these values in the Netlify Dashboard below. diff --git a/src/content/docs/workers/static-assets/migration-guides/vercel-to-workers.mdx b/src/content/docs/workers/static-assets/migration-guides/vercel-to-workers.mdx index 54413a24985..46ce37f5475 100644 --- a/src/content/docs/workers/static-assets/migration-guides/vercel-to-workers.mdx +++ b/src/content/docs/workers/static-assets/migration-guides/vercel-to-workers.mdx @@ -9,7 +9,7 @@ products: - workers --- -import { WranglerConfig } from "~/components"; +import { PackageManagers, WranglerConfig } from "~/components"; In this tutorial, you will learn how to migrate your Vercel application to Cloudflare Workers. @@ -19,6 +19,12 @@ You should already have an existing project deployed on Vercel that you would li Some frameworks like Next.js, Astro with on demand rendering, and others have specific guides for migrating to Cloudflare Workers. Refer to our [framework guides](/workers/framework-guides/) for more information. If your framework has a **Deploy an existing project on Workers** guide, follow that guide for specific instructions. Otherwise, continue with the steps below. +For supported frameworks and project types, Wrangler can [configure or deploy your project automatically](/workers/framework-guides/automatic-configuration/). From your project root, run: + + + +If Wrangler detects your project, confirm the generated settings. If Wrangler cannot detect your project or you need to adjust routing behavior, continue with the manual migration steps. + ## Find your build command and build directory To move your application to Cloudflare Workers, you will need to know your build command and build directory. Cloudflare Workers will use this information to build and deploy your application. We'll cover how to find these values in the Vercel Dashboard below. diff --git a/src/content/docs/workers/tutorials/deploy-an-express-app.mdx b/src/content/docs/workers/tutorials/deploy-an-express-app.mdx index 63a565491ae..930787a3ae2 100644 --- a/src/content/docs/workers/tutorials/deploy-an-express-app.mdx +++ b/src/content/docs/workers/tutorials/deploy-an-express-app.mdx @@ -31,6 +31,18 @@ This creates a repository in your GitHub account and deploys the application to You may wish to manually follow the steps if you are new to Cloudflare Workers. +If you already have an Express.js app and do not need the D1 steps in this tutorial, Wrangler can generate the Workers wrapper and `nodejs_compat` configuration for you: + +"} +/> + +For more information, refer to [Deploy an existing project](/workers/framework-guides/automatic-configuration/#deploy-a-specific-target). + +If your existing app uses `express.static()` or Node HTTP upgrade/WebSocket patterns, review the generated configuration. Static assets and WebSocket routes may require manual migration. + ## 1. Create a new Cloudflare Workers project Use [C3](https://developers.cloudflare.com/learning-paths/workers/get-started/c3-and-wrangler/#c3), the command-line tool for Cloudflare's developer products, to create a new directory and initialize a new Worker project: diff --git a/src/content/docs/workers/vite-plugin/index.mdx b/src/content/docs/workers/vite-plugin/index.mdx index b2e15669d52..b57331fa68f 100644 --- a/src/content/docs/workers/vite-plugin/index.mdx +++ b/src/content/docs/workers/vite-plugin/index.mdx @@ -34,4 +34,6 @@ To create a new application from a ready-to-go template, refer to the [TanStack To create a standalone Worker from scratch, refer to [Get started](/workers/vite-plugin/get-started/). +If you already have a static Vite app and do not need the Cloudflare Vite plugin, Wrangler can deploy it with `--experimental-auto-config-static-assets`. For more information, refer to [Deploy an existing project](/workers/framework-guides/automatic-configuration/#deploy-a-specific-target). + For a more in-depth look at adapting an existing Vite project and an introduction to key concepts, refer to the [Tutorial](/workers/vite-plugin/tutorial/). diff --git a/src/content/docs/workers/vite-plugin/tutorial.mdx b/src/content/docs/workers/vite-plugin/tutorial.mdx index 9ae1ae30e6b..a41c83ceb0c 100644 --- a/src/content/docs/workers/vite-plugin/tutorial.mdx +++ b/src/content/docs/workers/vite-plugin/tutorial.mdx @@ -18,6 +18,8 @@ Much of the content can also be applied to adapting existing Vite projects and t :::note If you want to start a new app with a template already set up with Vite, React and the Cloudflare Vite plugin, refer to the [React framework guide](/workers/framework-guides/web-apps/react/). To create a standalone Worker, refer to [Get started](/workers/vite-plugin/get-started/). + +If you only need to deploy an existing static Vite app, Wrangler can deploy it with `--experimental-auto-config-static-assets` without adding the Cloudflare Vite plugin. For more information, refer to [Deploy an existing project](/workers/framework-guides/automatic-configuration/#deploy-a-specific-target). ::: ## Introduction @@ -205,6 +207,7 @@ This opts out of interpreting the `Sec-Fetch-Mode` header. ``` + ::: ### Call the API from the client diff --git a/src/content/docs/workers/wrangler/commands/workers.mdx b/src/content/docs/workers/wrangler/commands/workers.mdx index 02f0a284c3f..b22643449ce 100644 --- a/src/content/docs/workers/wrangler/commands/workers.mdx +++ b/src/content/docs/workers/wrangler/commands/workers.mdx @@ -154,7 +154,7 @@ None of the options for this command are required. Many of these options can be Deploy your Worker to Cloudflare. -When you run `wrangler deploy` in a project directory without a Wrangler configuration file, Wrangler will [automatically detect your framework](/workers/framework-guides/automatic-configuration/) and configure your project for Cloudflare Workers. This command will prompt you to confirm the detected settings before applying changes. Confirm that you would like to proceed, and your project will be configured and deployed. +When you run `wrangler deploy` in a project directory without a Wrangler configuration file, Wrangler can [automatically detect your framework, project type, or deploy target](/workers/framework-guides/automatic-configuration/). This command prompts you to confirm the detected settings before applying changes. Confirm that you would like to proceed, and Wrangler configures and deploys your project. To deploy from an AI agent or another environment before Cloudflare authentication is available, use `wrangler deploy --temporary`. This flow requires Wrangler 4.102.0 or later. Wrangler creates or reuses a temporary preview account, deploys to that account, and prints a claim URL. For more information, refer to [Claim deployments](/workers/platform/claim-deployments/). @@ -171,15 +171,13 @@ None of the options for this command are required. Also, many can be set in your ::: - `PATH` - - A path specific what needs to be deployed, this can either be: - - The path to an entry point for your Worker. - - Only required if your [Wrangler configuration file](/workers/wrangler/configuration/) does not include a `main` key (for example, `main = "index.js"`). - - - Or the path to an assets directory for the deployment of a static site. - - Visit [assets](/workers/static-assets/) for more information. - - This overrides the eventual `assets` configuration in your [Wrangler configuration file](/workers/wrangler/configuration/). - - This is equivalent to the `--assets` option listed below. - - Note: this option currently only works only in interactive mode (so not in CI systems). + - The path to what Wrangler should deploy. This can be a Worker entrypoint, an Express-style Node HTTP server entrypoint, an HTML file, an assets directory, a static Vite app directory, a Dockerfile, or a Containerfile. + - A Worker entrypoint is only required if your [Wrangler configuration file](/workers/wrangler/configuration/) does not include a `main` key, for example `main = "index.js"`. + - To deploy a configured static site, pass an assets directory. This overrides the `assets` configuration in your Wrangler configuration file and is equivalent to the `--assets` option. This option works only in interactive mode. + - To deploy an HTML file without creating a Wrangler configuration file, pass the `.html` file directly. + - To deploy an explicit static directory without creating a Wrangler configuration file, pass a directory that contains `index.html`. + - To deploy a static Vite app directory without creating a Wrangler configuration file, pass the directory with `--experimental-auto-config-static-assets`. + - To configure and deploy a Dockerfile-backed Container project, pass `Dockerfile` or `Containerfile`. - `--name` - Name of the Worker. @@ -198,6 +196,8 @@ None of the options for this command are required. Also, many can be set in your - Use the latest version of the Workers runtime. - `--assets` - Folder of static assets to be served. Replaces [Workers Sites](/workers/configuration/sites/). Visit [assets](/workers/static-assets/) for more information. +- `--experimental-auto-config-static-assets` + - Deploy an explicit static Vite app directory without creating a Wrangler configuration file. Requires `PATH` to be a directory. - `--site` - Folder of static assets for Workers Sites. :::caution @@ -239,8 +239,8 @@ None of the options for this command are required. Also, many can be set in your - Specify the [Workers for Platforms dispatch namespace](/cloudflare-for-platforms/workers-for-platforms/how-workers-for-platforms-works/#dispatch-namespace) to upload this Worker to. - `--metafile` - Specify a file to write the build metadata from esbuild to. If flag is used without a path string, this defaults to `bundle-meta.json` inside the directory specified by `--outdir`. This can be useful for understanding the bundle size. -- `--containers-rollout` - - Specify the [rollout strategy](/containers/faq#how-do-container-updates-and-rollouts-work) for [Containers](/containers) associated with the Worker. If set to `immediate`, 100% of container instances will be updated in one rollout step, overriding any configuration in `rollout_step_percentage`. Note that `rollout_active_grace_period`, if configured, still applies. +- `--containers-rollout` + - Specify the [rollout strategy](/containers/platform-details/rollouts/) for [Containers](/containers/) associated with the Worker. If set to `immediate`, 100% of container instances will be updated in one rollout step, overriding any configuration in `rollout_step_percentage`. The `rollout_active_grace_period` setting still applies. If set to `none`, Wrangler deploys Worker changes without building or updating Containers. - Defaults to `gradual`, where the default rollout is 10% then 100% of instances. - `--strict` - Turns on strict mode for the deployment command, meaning that the command will be more defensive and prevent deployments which could introduce potential issues. In particular, this mode prevents deployments if the deployment would potentially override remote settings in non-interactive environments. @@ -282,6 +282,8 @@ wrangler delete [