From 555deeac654be0f8a798cbc24c3a2f4d26b956fc Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Fri, 15 Jul 2022 16:24:14 +0800 Subject: [PATCH] docs: note library mode process.env.* replacement (#9130) --- docs/guide/build.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/guide/build.md b/docs/guide/build.md index 5fe3c2a78e25f8..5aab94565c1bce 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -189,6 +189,10 @@ Recommended `package.json` for your lib: If the `package.json` does not contain `"type": "module"`, Vite will generate different file extensions for Node.js compatibility. `.js` will become `.mjs` and `.cjs` will become `.js`. ::: +::: tip Environment Variables +In library mode, all `import.meta.env.*` usage are statically replaced when building for production. However, `process.env.*` usage are not, so that consumers of your library can dynamically change it. If this is undesirable, you can use `define: { 'process.env.``NODE_ENV': '"production"' }` for example to statically replace them. +::: + ## Advanced Base Options ::: warning