1.0.6 • Published 1 year ago
@apad/env-tools v1.0.6
env-tools
easy read .env
, .env.*
to web bundler and use it in web
exm
first, create .env.dev
file in project root, config like
a=aaa
b=bbb
c=false
webpack config:
import { getDefinesObject } from '@apad/env-tools/lib/bundler'
module.export = {
// ...
plugins: [
// will read .env.dev
new webpack.DefinePlugin(getDefinesObject('dev'))
]
}
web:
import { getEnv } from '@apad/env-tools/lib/web'
console.log(getEnv().a)
console.log(process.env.b)
if you have some env only want to use in own machine, create a .env
file can cover every `.env.`*
some useful api
show quickly env configure modal
import { showEnvConfigureModal, extendEnv } from '@apad/env-tools/lib/web'
showEnvConfigureModal()
// if you want to show you own env in modal, use this extend
extendEnv({newA:111,newB:222})