0.1.2 • Published 29 days ago
@htmelt/env v0.1.2
@htmelt/env
Import environment variables from a file at build time.
This plugin is an alternative to using import.meta.env
and the
esbuild.define
config option, which is verbose and clumsy to setup.
Usage
Add the following to your tsconfig.json
compiler options:
"types": ["@htmelt/env/client"],
Then, anywhere in your project, you can use the inlinedEnvFile
function to
import environment variables from a file at build time.
interface Variables {
FOO: string
}
// The given path is relative to the current module. It can point to a file
// or a folder. If a folder is passed, a mode-specific file (e.g. ".env.development")
// will be used if it exists.
export const env = inlinedEnvFile<Variables>('./')
Install
pnpm install -D @htmelt/env
yarn add -D @htmelt/env
npm install --save-dev @htmelt/env
0.1.2
29 days ago