最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Can I use .dotenv library as HTML script imports only without npm or node.js? - Stack Overflow

programmeradmin1浏览0评论

Is there a way to use dotenv library as an import (e.g from CDN) only in a HTML script tag or .js file? I mean without node or npm require or imports.. Otherwise I would have to use something like webpack and I just want to test it quickly on a HTML page...

Is there a way to use dotenv library as an import (e.g from CDN) only in a HTML script tag or .js file? I mean without node or npm require or imports.. Otherwise I would have to use something like webpack and I just want to test it quickly on a HTML page...

Share Improve this question asked Oct 24, 2020 at 22:49 MarcLMarcL 3,5938 gold badges58 silver badges107 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

Short answer: No.

dotenv is a backend tool for getting variables set in a .env file. If you are using .env files for public use, that is misusing what the point of environment variables are for. Maybe try just using a filename.json or fileame.yml file for public consumption, but .env files are only used for secret things, like API keys, database passwords, etc.

发布评论

评论列表(0)

  1. 暂无评论