Skip to content

Commit ab0126f

Browse files
committed
More PR feedback
1 parent b846ffb commit ab0126f

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

src/content/docs/workers/vite-plugin/cloudflare-environments.mdx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,24 @@ vars = { MY_VAR = "Production var" }
3131

3232
</WranglerConfig>
3333

34-
If you run `CLOUDFLARE_ENV=production vite build` then the output `wrangler.json` file generated by the build will be a flattened configuration for the 'production' Cloudflare environment.
35-
This combines [top-level only](/workers/wrangler/configuration/#top-level-only-keys), [inheritable](/workers/wrangler/configuration/#inheritable-keys), and [non-inheritable](/workers/wrangler/configuration/#non-inheritable-keys) keys.
36-
The value of `MY_VAR` will therefore be `'Production var'`.
37-
The name of the Worker will be `'my-worker-production'` because the environment name is automatically appended to the top-level Worker name.
34+
If you run `CLOUDFLARE_ENV=production vite build` then the output `wrangler.json` file generated by the build will be a flattened configuration for the 'production' Cloudflare environment, as shown in the following example:
35+
36+
```json
37+
{
38+
"name": "my-worker",
39+
"compatibility_date": "2024-12-30",
40+
"main": "index.js",
41+
"vars": { "MY_VAR": "Production var" }
42+
}
43+
```
44+
45+
Notice that the value of `MY_VAR` is `Production var`.
46+
This flattened configuration combines [top-level only](/workers/wrangler/configuration/#top-level-only-keys), [inheritable](/workers/wrangler/configuration/#inheritable-keys), and [non-inheritable](/workers/wrangler/configuration/#non-inheritable-keys) keys.
3847

3948
:::note
4049
The default Vite environment name for a Worker is always the top-level Worker name.
4150
This enables you to reference the Worker consistently in your Vite config when using multiple Cloudflare environments.
51+
See [Vite Environments](/workers/vite-plugin/vite-environments/) for more information.
4252
:::
4353

4454
Cloudflare environments can also be used in development.

src/content/docs/workers/vite-plugin/migrating-from-wrangler-dev.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ There are a few key differences to highlight:
1515
With the Cloudflare Vite plugin, your Worker config file (for example, `wrangler.jsonc`) is the input configuration and a separate output configuration is created as part of the build.
1616
This output file is a snapshot of your configuration at the time of the build and is modified to reference your build artifacts.
1717
It is the configuration that is used for preview and deployment.
18-
Once you have run `vite build`, running `wrangler deploy` will automatically locate this output configuration file.
18+
Once you have run `vite build`, running `wrangler deploy` or `vite preview` will automatically locate this output configuration file.
1919

2020
### Cloudflare Environments
2121

@@ -30,7 +30,7 @@ If these options are provided, then warnings will be printed to the console with
3030
Examples where the Vite configuration should be used instead include `alias` and `define`.
3131
See [Vite Environments](/workers/vite-plugin/vite-environments/) for more information about configuring your Worker environments in Vite.
3232

33-
### Local only data during local development
33+
### No remote mode
3434

3535
The Vite plugin does not support [remote mode](/workers/local-development/#develop-using-remote-resources-and-bindings).
3636
We will be adding support for accessing remote resources in local development in a future update.

src/content/docs/workers/vite-plugin/secrets.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ description: Using secrets with the Vite plugin
99

1010
import { PackageManagers, WranglerConfig } from "~/components";
1111

12-
Secrets can be provided to your Worker in local development using a [`.dev.vars`](/workers/configuration/secrets/#local-development-with-secrets) file.
12+
Secrets are typically used for storing sensitive information like API keys an auth tokens.
13+
For deployed Workers, they are set via the dashboard or Wrangler CLI.
14+
See [Secrets](/workers/configuration/secrets/) for more information.
15+
16+
In local development, secrets can be provided to your Worker by using a [`.dev.vars`](/workers/configuration/secrets/#local-development-with-secrets) file.
1317
If you are using [Cloudflare Environments](/workers/vite-plugin/cloudflare-environments/) then the relevant `.dev.vars` file will be selected.
1418
For example, `CLOUDFLARE_ENV=staging vite dev` will load `.dev.vars.staging` if it exists and fall back to `.dev.vars`.
1519

src/content/docs/workers/vite-plugin/static-assets.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ For more information about using static assets in Vite, refer to [Static Asset H
1616
The Vite plugin does not require that you provide the `assets` field in order to enable assets and instead determines whether assets should be included based on whether the `client` environment has been built.
1717
By default, the `client` environment is built if there is an `index.html` file in the root of your project or if `build.rollupOptions.input` is specified in the Vite config.
1818

19-
On running `vite build`, an output `wrangler.json` configuration file is included as part of the build output.
19+
On running `vite build`, an output `wrangler.json` configuration file is generated as part of the build output.
2020
The `assets.directory` field in this file is automatically populated with the path to your `client` build output.
2121
It is therefore not necessary to provide the `assets.directory` field in your input Worker configuration.
2222

src/content/docs/workers/vite-plugin/vite-environments.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ By default, when you add a Worker using the Cloudflare Vite plugin, an additiona
2121
Its name is derived from the Worker name, with any dashes replaced with underscores.
2222
This name can be used to reference the environment in your Vite config in order to apply environment specific configuration.
2323

24+
:::note
25+
The default Vite environment name for a Worker is always the top-level Worker name.
26+
This enables you to reference the Worker consistently in your Vite config when using multiple [Cloudflare Environments](/workers/vite-plugin/cloudflare-environments/).
27+
:::
28+
2429
### Environment configuration
2530

2631
In the following example we have a Worker named `my-worker` that is associated with a Vite environment named `my_worker`.

0 commit comments

Comments
 (0)