Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support .env file for production / preview node preset #1492

Open
pi0 opened this issue Jul 26, 2023 · 6 comments
Open

Support .env file for production / preview node preset #1492

pi0 opened this issue Jul 26, 2023 · 6 comments
Labels
discussion enhancement New feature or request node

Comments

@pi0
Copy link
Member

pi0 commented Jul 26, 2023

It is quite often required to test production Node.js preset outputs with dotenv file. I am thinking of 3 possible ways:

  • Change preview command to node -r require/dotenv .output/server/index.mjs (user needs dotenv local dependency)
  • Support a preview command used by nitro (and other frameworks such as nuxi)
  • Enable feature by default (as a bundled runtime)
  • Enable feature behind a flag (can be enabled by a CLI flag)

Need to check how much is actual runtime overhead of dotenv (it seems as low as 5KB).

Also worth to node that, the "local" kind presets (Bun and Deno) both already have built-in dotenv support via CLI args. And there is an ongoing discussion within Node.js team to make it build-in feature..

@Hebilicious
Copy link
Member

Hebilicious commented Jul 26, 2023

For cloudflare presets previews, there's builtin dotenv supports too, but the file needs to be named .dev.vars

@pi0
Copy link
Member Author

pi0 commented Jul 26, 2023

Good to know! My aim for this issue was mainly for Node presets but having other preset previews in mind, we might either leverage possible preview command or guide with args to use .env

@gyhyfj
Copy link

gyhyfj commented Aug 1, 2023

Currently, append --dotenv .env.local to dev or build script doesn't work like nuxt, is it?

@danielroe
Copy link
Member

Note that this feature should be coming to Node natively in 20.6.

nodejs/node#49185

@gyhyfj
Copy link

gyhyfj commented Aug 21, 2023

what if running in serverless environment rather than node server in future?

@Hebilicious
Copy link
Member

Note that this feature should be coming to Node natively in 20.6.

nodejs/node#49185

Turns out the strong competition provided by deno and bun is working. We might have TS support in node at this rate 🤞🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request node
Projects
None yet
Development

No branches or pull requests

4 participants