esbuild-plugin-environment
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

esbuild-plugin-environment

Build Status

Install

npm install esbuild-plugin-environment -D

Usage

Add the plugin to your esbuild plugins.

Example esbuild.config.cjs file:

const { environmentPlugin } = require('esbuild-plugin-environment');

module.exports = () => {
  const config = {
    bundle: true,
    sourcemap: true,
    platform: 'node',
    target: 'es2022',
    format: 'esm',
    outputFileExtension: '.mjs',
    environment: {},
    concurrency: 4,
    watch: {
      pattern: ['./src/**'],
      ignore: ['dist', 'node_modules'],
    },
    plugins: [
      // process.env key => default value
      environmentPlugin({
        BUILD_TIMESTAMP: new Date().toISOString(),
      }),
      // Array of process.env keys
      environmentPlugin(['PWD', 'npm_package_version']),
    ],
  };

  return config;
};

Package Sidebar

Install

npm i esbuild-plugin-environment

Weekly Downloads

1,133

Version

0.4.0

License

MIT

Unpacked Size

6.34 kB

Total Files

8

Last publish

Collaborators

  • webdeveric