Skip to content

Commit b816f7a

Browse files
add a changeset
1 parent f091909 commit b816f7a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

.changeset/moody-breads-pump.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
"@cloudflare/vite-plugin": minor
3+
"wrangler": minor
4+
---
5+
6+
Add support for loading local dev vars from .env files
7+
8+
If there are no `.dev.vars` or `.dev.vars.<environment>` files, when running Wrangler or the Vite plugin in local development mode,
9+
they will now try to load additional local dev vars from `.env`, `.env.local`, `.env.<environment>` and `.env.<environment>.local` files.
10+
11+
These loaded vars are only for local development and have no effect in production to the vars in a deployed Worker.
12+
Wrangler and Vite will continue to load `.env` files in order to configure themselves as a tool.
13+
14+
Further details:
15+
16+
- In `vite build` the local vars will be computed and stored in a `.dev.vars` file next to the compiled Worker code, so that `vite preview` can use them.
17+
- The `wrangler types` command will similarly read the `.env` files (if no `.dev.vars` files) in order to generate the `Env` interface.
18+
- If the `CLOUDFLARE_INCLUDE_PROCESS_ENV` environment variable is `true` then all the environment variables found on `process.env` will be included as local dev vars.
19+
- Wrangler (but not Vite plugin) also now supports the `--env-file=<path/to/dotenv/file>` global CLI option. This affects both loading `.env` to configure Wrangler the tool as well as loading local dev vars.

0 commit comments

Comments
 (0)