1.0.6 • Published 1 year ago

@apad/env-tools v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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})
1.0.6

1 year ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago