-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Vite plugin]: add programmatic worker config #26819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: production
Are you sure you want to change the base?
Conversation
|
This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:
|
| export default defineConfig({ | ||
| plugins: [ | ||
| cloudflare({ | ||
| configure: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first time I read this I didn't quite follow:
- the relationship between the object you pass into
configureandwrangler.jsonc(I can intuit it, but it didn't jump off the page to me) - if
configurecould basically be passed anything fromwrangler.jsoncor if it only supported a subset of values
I think I know with context from working on Workers what the answers to these are, but wonder if it's worth making extra explicit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@irvinebroque good point. Added here 6e798b0
jamesopstad
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really great documentation! Thanks @ascorbic.
Have approved but left a few minor comments to be resolved.
|
|
||
| When using the [Cloudflare Vite plugin](/workers/vite-plugin/) to build and deploy Workers, a Wrangler configuration file is now optional for assets-only (static) sites. If no `wrangler.toml`, `wrangler.json`, or `wrangler.jsonc` file is found, the plugin generates sensible defaults for an assets-only site. The `name` is based on the `package.json` or the project directory name, and the `compatibility_date` uses the latest date supported by your installed Miniflare version. | ||
|
|
||
| This allows easier setup for static sites and Vite-based single-page applications (SPAs) that do not require custom Worker configuration. No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a note here that assets.not_found_handling still needs to be set to single-page-application for SPA? This is likely to trip people up otherwise.
src/content/changelog/workers/2025-12-02-vite-programmatic-config.mdx
Outdated
Show resolved
Hide resolved
src/content/docs/workers/vite-plugin/reference/programmatic-configuration.mdx
Outdated
Show resolved
Hide resolved
| import { WranglerConfig } from "~/components"; | ||
|
|
||
| The Wrangler configuration file is optional when using the Cloudflare Vite plugin. Without one, the plugin uses default values. You can customize Worker configuration programmatically with the `config` option. This is useful when the Cloudflare plugin runs inside another plugin or framework. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| :::note | |
| Configuration provided via the `config` option will not be included when running `wrangler types` or when running resource based Wrangler CLI commands such as `wrangler kv`, `wrangler d1` etc. | |
| ::: | |
I think we need something to this effect to discourage users from defining configuration this way by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I actually wrote something but never committed it! I was wondering if it was worth saying how to manually add types, but I don't think we document that anywhere do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in chat, I don't think this is documented but it can be done via declaration merging.
Summary
Adds documentation for the Vite plugin's upcoming
configoption. As well as documenting the option itself, I have added a guide explaining programmatic configuration in more detail. I've included changelogs for this as well as the related support for zero-config workers.Code: cloudflare/workers-sdk#11445
Screenshots (optional)
Documentation checklist