【文件属性】:
文件名称:babel-plugin-dotenv-import:使用import语句加载环境变量
文件大小:118KB
文件格式:ZIP
更新时间:2021-01-31 02:24:28
babel dotenv babel-plugin environment-variables BabelJavaScript
babel-plugin-dotenv-import
使用import语句加载环境变量。
安装
$ npm install babel-plugin-dotenv-import
用法
.babelrc
{
" plugins " : [
[ " dotenv-import " , {
" moduleName " : " @env " ,
" path " : " .env " ,
" blacklist " : null ,
" whitelist " : null ,
" safe " : false ,
" allowUndefined " : false
}]
]
}
.env
API_URL =https://api.example.org
API_TOKEN =
在users.js中
import { API_URL , API_TOKEN } from "@env"
fetch ( ` ${ API_URL } /users` , {
headers : {
【文件预览】:
babel-plugin-dotenv-import-master
----yarn.lock(252KB)
----.circleci()
--------config.yml(2KB)
----LICENSE(1KB)
----__tests__()
--------index.test.js(4KB)
--------__fixtures__()
----README.md(3KB)
----.editorconfig(147B)
----.gitignore(43B)
----index.js(2KB)
----package.json(2KB)