Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback

esbuild-plugin-env

This is an esbuild plugin that exports the current environment as a module, allowing you to embed environment variables in your build.

Usage

Here’s an example of usage in Deno. Let’s say you have a module secret.js that exports a secret:

export {SECRET as default} from 'env'

You can bundle it like this:

Deno.env.set('SECRET', '********')

await build({
  bundle: true,
  format: 'esm',
  entryPoints: ['secret.js'],
  plugins: [env]
})

This will result in this code:

var SECRET = "********";
export {
  SECRET
};