Skip to content

An esbuild plugin that exports the current environment as a module

License

Notifications You must be signed in to change notification settings

jed/esbuild-plugin-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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} from 'env'

You can bundle it like this:

import {build} from 'https://deno.land/x/esbuild@v0.13.15/mod.js'
import env from 'https://deno.land/x/esbuild_plugin_env@v1.0.0/mod.js'

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
};

About

An esbuild plugin that exports the current environment as a module

Resources

License

Stars

Watchers

Forks

Packages

No packages published