netlify / ask-netlify

A place to submit questions for Netlify to answer in tutorials, podcasts and blog posts
https://ask.netlify.com
32 stars 8 forks source link

Recommended way to set .env #9

Closed nathanheffley closed 5 years ago

nathanheffley commented 5 years ago

About me

My question in a little more detail

I have a Vue CLI based project which uses some .env files to set some values to be used in the build process. Since it's a frontend project (project for reference) the key isn't particularly sensitive amd I've just committed the files, but it makes it more difficult for users who want to change the setting for local testing with their own keys.

I haven't been able to find any good recommendations or examples of how to handle setting variables in a way that's also friendly to local development or deploying to non-Netlify systems.

Thanks in advance for any suggestions!

philhawksworth commented 5 years ago

https://www.npmjs.com/package/dotenv is your friend. (In conjunction with environment variables as supported by Netlify and most comparable platforms)