Skip to content

Instantly share code, notes, and snippets.

@wellic
Created November 6, 2019 12:04
Add env vars to js applications
1) Способ доставки в приложение любых переменных в яваскрипт
https://www.simonewebdesign.it/how-to-get-environment-variables-in-the-browser/
2) А это как применить красиво
https://engineering.contaazul.com/handling-environment-variables-in-the-browser-bbde35661798
Идея:
1) генерим любым способом json-файл vars.js вида:
window.my_vars = {
v1: ...,
v2: ...
}
2) в html вставляем <script src="vars.js"></script>
3) пользуемся переменныными:
<script>
console.log(my_vars.v1 + '@' + my_vars.v2);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment