From c8b5b75d5d897077880151d9e4e40e8ba8bb06dc Mon Sep 17 00:00:00 2001 From: Romuald Brillout Date: Thu, 4 Jul 2024 13:25:06 +0200 Subject: [PATCH] docs: add note about import.meta.env in config files (#1726) --- docs/pages/env/+Page.mdx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/pages/env/+Page.mdx b/docs/pages/env/+Page.mdx index 5f729aac80..b713aa8f1e 100644 --- a/docs/pages/env/+Page.mdx +++ b/docs/pages/env/+Page.mdx @@ -65,6 +65,13 @@ The following environment variables can be accessed from the client-side without +## Config files + +Note that [`import.meta.env` isn't available in config files](https://github.com/vikejs/vike/issues/1726#issuecomment-2208626928) (neither `vite.config.js` nor `+config.js`). + +> A workaround is to use [`process.env`](https://nodejs.org/en/learn/command-line/how-to-read-environment-variables-from-nodejs) instead of `import.meta.env`. But note that you'll then only be able to access environment variables coming from your operating system (you won't be able to access those defined in `.env` files). + + ## See also - [#1726 Improve environment variables support](https://github.com/vikejs/vike/issues/1726)