Skip to content

Vite plugin v2 - Load local Worker secrets using the Vite mode - #15507

Open
jamesopstad wants to merge 1 commit into
vite-plugin-v2-06-child-environmentsfrom
vite-plugin-v2-07-local-secrets
Open

Vite plugin v2 - Load local Worker secrets using the Vite mode#15507
jamesopstad wants to merge 1 commit into
vite-plugin-v2-06-child-environmentsfrom
vite-plugin-v2-07-local-secrets

Conversation

@jamesopstad

Copy link
Copy Markdown
Contributor

Vite plugin v2 - Load local Worker secrets using the Vite mode

.env and .dev.vars resolution and merging now uses the Vite mode and is decoupled from Wrangler.

vite preview now uses the mode in the build output to determine which .env/.dev.vars files to load. Local secrets in preview are therefore no longer stored in a separate .dev.vars file.


  • 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: release notes to follow

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

@jamesopstad jamesopstad added the ci:no-changeset-required Skip pull request checks for a valid changeset label Sep 4, 2026
@changeset-bot

changeset-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c9818cb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@pkg-pr-new

pkg-pr-new Bot commented Sep 4, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

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

@cloudflare/build-output-utils

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

@cloudflare/codemods

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

@cloudflare/config

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

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-plugin

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: c9818cb

@jamesopstad
jamesopstad marked this pull request as ready for review September 4, 2026 09:13

@devin-ai-integration devin-ai-integration Bot 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.

Devin Review found 1 potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Comment on lines +367 to +370
const [localEnv, devVars] = await Promise.all([
loadEnv(envDir, localEnvMode),
loadDevVars(envDir, localEnvMode),
]);

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.

🟡 Cloudflare tool settings stop loading

When .env defines Cloudflare tool settings, loadEnv keeps them from existing process-based consumers. Remote bindings and other development services then ignore those settings.

Prompt for agents
Preserve support for Cloudflare tool settings loaded from Vite env files without globally copying every local Worker secret into process.env. Audit the consumers that previously relied on the prefixed values copied in resolvePluginConfig, including remote-binding authentication and Cloudflare account, compliance, API, and Hyperdrive settings. Pass the loaded values explicitly where possible, or introduce a narrowly scoped compatibility bridge for the supported tool prefixes. Retain the new localEnv and devVars behavior for Worker secret bindings.
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@ask-bonk

ask-bonk Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@jamesopstad Bonk workflow was cancelled.

View workflow run · To retry, trigger Bonk again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:no-changeset-required Skip pull request checks for a valid changeset

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants