How to access process.env #725
richardpickett
started this conversation in
General
Replies: 1 comment
-
@egoist please help up on this question. And I also want to know, if I set compile-time environment variables like |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a simple .js based library with a couple handy classes that are ran in the browser.
One of the classes accesses the env like this:
process?.env?.SOME_VAR
.I use
tsup src/index.js --format cjs,esm --dts --clean --minify
to build the package and thennpm publish
.When I don't use tsup and just cp all the .js into the dist folder, it works just fine, the class can access the env just fine.
But when I compile with tsup, the class can't access any values in process.env in the app that
npm import
s it.What's the right way to (a) compile the package for publishing so that (b) when it's imported it can read process.env in the app which imports it.
Beta Was this translation helpful? Give feedback.
All reactions