Use code generation for putting environment variables into a ts file #2023
AndKiel
started this conversation in
Show and tell / tips
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
If you don't like loaders or putting ENV on the window that's mentioned in the official docs, you can easily use code generation (
ts-morph
or native API) to create a config file that exports a constant with your values.For code generation, I had to create a separate tsconfig file and override
module
tocommonjs
. Otherwise, I was getting various errors about file extension or imports.A simple script using
ts-node
could look like this:With the script being:
we would get the following file:
I hope it can help anyone struggling with using environment variables in remix.
Beta Was this translation helpful? Give feedback.
All reactions