I work on a single page Elm app at work. We run the app locally while developing it, on a staging server, and in production. With this, we have different servers and API keys we use in each environment. Up until now, we’ve been passing these values into the app with flags and storing it in
Main's model. This got kind of frustrating because have 30+ pages and we have to pass the server URL to every page’s
update function along with various API keys depending on the page.
I wanted to refer to these values like regular variables, but since they were passed in as flags at runtime, we couldn’t. To do this, I wrote a tool that allows you to specify environment variables and generate an Elm file with those values so you can access them anytime, anywhere in the program. We use
elm-graphql as well so I just added this tool to our pre-build process and it worked like a charm. I thought it may be helpful to others in the community, so I moved it to it’s own package and published it!