You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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