esbuild Config Generator
Generates a ready esbuild.config.js for fast builds, with entry point, bundle, minification, sourcemap and target already set. The output format is left at the esbuild default.
A ready esbuild build script
esbuild is fast and has one gotcha that catches almost everyone the first time: it never looks for a config file on its own. Either you pile flags onto the command line until your package.json script turns into a paragraph, or you write a small build script in JavaScript. This page hands you that script already written.
The block is fixed, has no fields, and shows up as soon as the page loads. It calls require('esbuild') and passes esbuild.build entryPoints src/index.js, bundle true, outfile dist/bundle.js, minify true, sourcemap true, target es2020 and platform browser, ending with a catch that exits with code 1. Save it as esbuild.config.js and run node esbuild.config.js, or wire it into your build script.
Three things to check. The file uses require, so it breaks if your package.json has type: module; rename it to .cjs or convert it to import syntax. platform browser means Node builtins like fs and path will fail to resolve, so switch to node for a CLI tool. And there is no watch mode: since 0.17 that lives in the context API, with esbuild.context and ctx.watch. The text is assembled in your browser.
Frequently asked questions
Does esbuild pick this file up automatically?
How do I get watch mode?
How do I emit an ESM bundle?
Related Tools
Webpack Config Generator
Generate a minimal webpack.config.js.
Rollup Config Generator
Generates a rollup.config.js to bundle libraries as ESM and CommonJS, with the node-resolve, commonjs and terser plugins already wired. A fixed block, ready to tweak.
Cloudflare wrangler.toml Generator
Generates a wrangler.toml for Cloudflare Workers, with name, compatibility date, environment variables and a KV namespace. Routes are yours to add.