Skip to content

Use CLOUDFLARE_PREVIEW_BUILD environment variable for preview delegation - #15817

Merged
jamesopstad merged 2 commits into
mainfrom
james/preview-build-environment-variable
Sep 24, 2026
Merged

jamesopstad merged 2 commits into
mainfrom
james/preview-build-environment-variable

Conversation

@jamesopstad

Copy link
Copy Markdown
Contributor

Support Preview builds through CLOUDFLARE_PREVIEW_BUILD environment variable when using the experimental config

Framework-owned build commands can now preserve Preview build context while producing Cloudflare Build Output. The internal Vite and Wrangler delegates consume the same environment variable instead of requiring a delegate-specific --preview flag.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: experimental feature

A picture of a cute animal (not mandatory, but encouraged)

@changeset-bot

changeset-bot Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d6c5564

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@cloudflare/vite-plugin Minor
wrangler Minor
@cloudflare/vitest-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ask-bonk

ask-bonk Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

@pkg-pr-new

pkg-pr-new Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@15817

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15817

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@15817

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@15817

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@15817

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@15817

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@15817

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@15817

miniflare

npm i https://pkg.pr.new/miniflare@15817

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15817

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@15817

@cloudflare/runtime-types

npm i https://pkg.pr.new/@cloudflare/runtime-types@15817

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@15817

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@15817

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@15817

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@15817

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@15817

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@15817

wrangler

npm i https://pkg.pr.new/wrangler@15817

commit: d6c5564

@jamesopstad
jamesopstad marked this pull request as ready for review September 23, 2026 21:53
@workers-devprod
workers-devprod requested review from a team and tpmmorris and removed request for a team September 23, 2026 21:53
@workers-devprod

workers-devprod commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

devin-ai-integration[bot]

This comment was marked as resolved.

@jamesopstad
jamesopstad force-pushed the james/preview-build-environment-variable branch from 826cb1c to 6c29f28 Compare September 23, 2026 21:59

@petebacondarwin petebacondarwin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic looks fine. I think the changeset needs tweaking though - a casual reader of the changelogs for Wrangler and Vite plugin would struggle to understand what this change means.

Comment thread .changeset/tidy-preview-builds.md Resolved

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codeowners reviews satisfied

@jamesopstad
jamesopstad force-pushed the james/preview-build-environment-variable branch from 6c29f28 to d6c5564 Compare September 24, 2026 08:54
@jamesopstad
jamesopstad merged commit 6e77c53 into main Sep 24, 2026
60 checks passed
@jamesopstad
jamesopstad deleted the james/preview-build-environment-variable branch September 24, 2026 09:20
Wichtowski pushed a commit to Wichtowski/workers-sdk that referenced this pull request Sep 24, 2026
brandhaug added a commit to brandhaug/b2b-saas-starter that referenced this pull request Sep 27, 2026
## pnpm-workspace.yaml (default)

## Dependency Updates

| Package | From | To | Type |
| --- | --- | --- | --- |
| `wrangler` | 4.136.2 | 4.138.0 | minor |

## Release Notes

<details>
<summary><b>wrangler</b> (4.136.2 → 4.138.0) — 3 releases</summary>

<details>
<summary><b>4.138.0</b></summary>

### Minor Changes

- [#15776](cloudflare/workers-sdk#15776)
[`b03f960`](cloudflare/workers-sdk@b03f960)
Thanks [@<!---->edevil](https://github.com/edevil)! - Add event-code
support to temporary Worker deployments

Use `wrangler deploy --temporary --event-code <code>` to provision an
account for an event. Wrangler requires explicit server acknowledgement
before caching the account and keeps the event code out of its cache and
telemetry.

- [#15817](cloudflare/workers-sdk#15817)
[`6e77c53`](cloudflare/workers-sdk@6e77c53)
Thanks [@<!---->jamesopstad](https://github.com/jamesopstad)! - Allow
framework commands to produce Preview Build Output with the experimental
config

When `cf previews deploy` invokes a framework build command, Preview
intent is now preserved. Function-based `cloudflare.config.ts` files
receive `isPreview: true`, and generated Build Output is marked as a
Preview build.

### Patch Changes

- [#15806](cloudflare/workers-sdk#15806)
[`8fade73`](cloudflare/workers-sdk@8fade73)
Thanks [@<!---->NuroDev](https://github.com/NuroDev)! - Standardize Zod
validation error output

Format validation errors with Zod's built-in `prettifyError()` helper so
Miniflare, Wrangler, the Vite plugin, and the Vitest plugin show
consistent messages and property paths.

- Updated dependencies
[[`a71237a`](cloudflare/workers-sdk@a71237a),
[`8fade73`](cloudflare/workers-sdk@8fade73)]:
  - [email protected]

</details>

<details>
<summary><b>4.137.0</b></summary>

### Minor Changes

- [#15778](cloudflare/workers-sdk#15778)
[`cd7508c`](cloudflare/workers-sdk@cd7508c)
Thanks [@<!---->jamesopstad](https://github.com/jamesopstad)! - Generate
types during development and supported builds with Vite's
`experimental.newConfig` option or Wrangler's
`--experimental-new-config` flag (and `--experimental-cf-build-output`
for builds)

When Wrangler's `--experimental-new-config` flag or Vite's
`experimental.newConfig` option is enabled, inferred configuration and
runtime declarations are now kept in `.cloudflare/types/index.d.ts`.
Vite refreshes them during development and production builds. Wrangler
refreshes them during development and when building with both
`--experimental-new-config` and `--experimental-cf-build-output`. In the
experimental `wrangler.config.ts` format, the `types` option is now
top-level because it applies to both commands.

### Patch Changes

- [#15765](cloudflare/workers-sdk#15765)
[`1bdb96d`](cloudflare/workers-sdk@1bdb96d)
Thanks [@<!---->th0m](https://github.com/th0m)! - Prepare the required
egress sidecar for local Containers without configured images

Wrangler dev and Vite dev/preview now pull the required sidecar for
Durable Object-managed Containers that select their application image at
start time. Previously, these Containers failed to start unless the
sidecar image was already cached in Docker.

- [#15712](cloudflare/workers-sdk#15712)
[`f5605f5`](cloudflare/workers-sdk@f5605f5)
Thanks [@<!---->alsuren](https://github.com/alsuren)! - Match D1 SQL
statement splitting to the local SQLite runtime

Wrangler now uses SQLite's statement-completion state machine when
splitting D1 SQL files. This keeps trigger, quoted identifier, comment,
and keyword handling consistent with local exe

…[full
notes](https://github.com/cloudflare/workers-sdk/releases/tag/wrangler%404.137.0)

</details>

<p><i>…and 1 more release(s) not shown</i></p>

</details>

---
*This PR was auto-generated by
[catalog-update-action](https://github.com/brandhaug/catalog-update-action).*

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants