Gulp Esbuild Plugin

0.14.1 · active · verified Tue Apr 21

The `gulp-esbuild` package provides a Gulp plugin that integrates the high-performance `esbuild` bundler into Gulp-based build workflows. It allows developers to efficiently bundle, minify, and transform JavaScript and TypeScript assets as part of their Gulp pipelines, leveraging `esbuild`'s speed. The current stable version is 0.14.1, and the package frequently releases updates, often in response to breaking changes in the upstream `esbuild` library. A key feature is the ability to enable `esbuild`'s incremental build mode via the `createGulpEsbuild` factory function, which significantly speeds up rebuilds during development when combined with Gulp's `watch` API. Unlike direct `esbuild` usage, `gulp-esbuild` is designed to work with Gulp's virtual file streams, but it has a specific limitation: all input files specified in `gulp.src()` must physically exist on the filesystem, even if their contents are subsequently modified by earlier Gulp pipeline steps.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to bundle a TypeScript file (`index.tsx`) using `gulp-esbuild` into a single JavaScript file (`bundle.js`) and output it to the `dist` directory, including minification and sourcemaps.

import { src, dest } from 'gulp';
import gulpEsbuild from 'gulp-esbuild';

/**
 * Gulp task to build a TypeScript application using gulp-esbuild.
 * It bundles 'index.tsx', configures esbuild for bundling and TSX loading,
 * and outputs the result to 'dist/bundle.js'.
 */
function build() {
    return src('./index.tsx')
        .pipe(gulpEsbuild({
            outfile: 'bundle.js',
            bundle: true,
            loader: {
                '.tsx': 'tsx'
            },
            minify: true,
            sourcemap: 'external'
        }))
        .pipe(dest('./dist'));
}

export { build };
// To run: `npx gulp build` (assuming 'gulp' is installed globally or via npx)

view raw JSON →