New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

esbuild-env-plugin

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-env-plugin

A Plugin for ESBuild that allows importing .env files directly into process.env or as object

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

esbuild-env-plugin

A plugin that enables importing .env files. If the build platform is 'node', variables will be added to process.env

Installation

You can install the esbuild-env-plugin package using npm or yarn:

npm install esbuild-env-plugin --save-dev

or

yarn add esbuild-env-plugin --dev

Usage

To use the esbuild-env-plugin, follow these steps:

  • Import the plugin at the top of your esbuild configuration file:
const { EnvPlugin } = require('esbuild-env-plugin'); // OR
import { EnvPlugin } from 'esbuild-env-plugin';
  • Add the plugin to your esbuild configuration:
const buildContext = await context({
  entryPoints: ['./index.ts'],
  plugins: [EnvPlugin()],
  outdir: './dist',
  bundle: true,
  format: 'esm',
  platform: 'node',
  tsconfig: './tsconfig.json',
  logLevel: 'info'
});
  • In your code, you can now import .env files as object:
//Import worker. It is important to include the file ending, otherwise its imported as module not as worker
import env from './example.env';

env.MY_VAR // or if platform is node
process.env.MY_VAR

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

esbuild

FAQs

Package last updated on 29 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts