webdeveric / esbuild-plugin-define

esbuild plugin to define global identifiers

Home Page:https://www.npmjs.com/package/esbuild-plugin-define

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

esbuild-plugin-define

Build Status

Install

npm install esbuild-plugin-define -D

Usage

Add the plugin to your esbuild plugins.

Example esbuild.config.cjs file:

const { definePlugin } = require('esbuild-plugin-define');

module.exports = () => {
  const config = {
    bundle: true,
    sourcemap: true,
    platform: 'node',
    target: 'es2022',
    format: 'esm',
    outputFileExtension: '.mjs',
    define: {},
    concurrency: 4,
    watch: {
      pattern: ['./src/**'],
      ignore: ['dist', 'node_modules'],
    },
    plugins: [
      definePlugin({
        process: {
          env: {
            BUILD_TIMESTAMP: new Date().toISOString(),
          },
        },
      }),
    ],
  };

  return config;
};

About

esbuild plugin to define global identifiers

https://www.npmjs.com/package/esbuild-plugin-define

License:MIT License


Languages

Language:TypeScript 85.6%Language:JavaScript 14.4%