Skip to content

Commit

Permalink
docs: clarify env replacement gotcha (#4843)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Sep 4, 2021
1 parent 5bc0ffc commit 46ecda4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/guide/env-and-mode.md
Expand Up @@ -16,7 +16,7 @@ Vite exposes env variables on the special **`import.meta.env`** object. Some bui

During production, these env variables are **statically replaced**. It is therefore necessary to always reference them using the full static string. For example, dynamic key access like `import.meta.env[key]` will not work.

It will also replace these strings appearing in JavaScript strings and Vue templates. This should be a rare case, but it can be unintended. There are ways to work around this behavior:
It will also replace these strings appearing in JavaScript strings and Vue templates. This should be a rare case, but it can be unintended. You may see errors like `Missing Semicolon` or `Unexpected token` in this case, for example when `"process.env.NODE_ENV: "` is transformed to `""development": "`. There are ways to work around this behavior:

- For JavaScript strings, you can break the string up with a unicode zero-width space, e.g. `'import.meta\u200b.env.MODE'`.

Expand Down

0 comments on commit 46ecda4

Please sign in to comment.