Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Setting Environment Variables for preset-node #319

Closed
trusktr opened this issue Sep 15, 2017 · 5 comments
Closed

Setting Environment Variables for preset-node #319

trusktr opened this issue Sep 15, 2017 · 5 comments

Comments

@trusktr
Copy link
Contributor

trusktr commented Sep 15, 2017

I'd like for an app that I run with neutrino-preset-node to use real environment variables (not transpiled in).

How can we do this?

@eliperelman
Copy link
Member

Node.js still has access to process.env and environment variables won't be transpiled in unless you use a Webpack plugin or the env middleware to force it to. For example, if you had the following code:

console.log(process.env.TEST);

and ran the build with:

TEST="hello world" neutrino build

Your built file won't contain the string "hello world". It will still contain the call to process.env.TEST and it will be pulled at runtime (e.g. when the Node.js process starts).

Hope that answers your question. 👍

@trusktr
Copy link
Contributor Author

trusktr commented Sep 15, 2017 via email

@trusktr
Copy link
Contributor Author

trusktr commented Sep 16, 2017

I ended up making a webpack plugin to start/restart the server using child_process.exec on compiler after-emit event.

@timkelty
Copy link
Contributor

timkelty commented May 1, 2018

@trusktr @eliperelman I believe the confusion here may be related this bug: #839

@edmorley
Copy link
Member

@trusktr does the issue you were seeing sound like #839?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants