cosmic-esbuild
Simplifying esbuild configurations in a familiar way.

Description
This package allows you declaratively configure esbuild
using the popular cosmiconfig
format. No more custom build scripts, no more lengthy build commands in your manifest.
Installation
npm install cosmic-esbuild
Usage
Configuration
Create a file for your configuration, see the following examples:
JSON
{
"entryPoints": ["app.js"],
"bundle": true,
"sourcemap": "external",
"outdir": "lib"
}
YAML
bundle: true
entryPoints:
- "app.js"
outdir: "lib"
sourcemap: "external"
TOML
bundle = true
entryPoints = [ "app.js" ]
outdir = "lib"
sourcemap = "external"
TypeScript
import type { BuildOptions } from "esbuild";
const config = {
bundle: true,
entryPoints: ["app.js"],
outdir: "dist",
sourcemap: "external",
} satisfies BuildOptions;
export default config;
package.json
{
"name": "your-package",
"scripts": {
"build": "cosmic-esbuild",
"dev": "cosmic-esbuild --watch"
},
"esbuild": {
"bundle": true,
"entryPoints": ["app.js"],
"outdir": "lib",
"sourcemap": "external"
}
}
Supported formats
You can write your configuration to any of the following formats (sorted by precedence):
package.json
(add the esbuild
property with your config)
.esbuildrc
.esbuildrc.json
.esbuildrc.jsonc
.esbuildrc.yaml
.esbuildrc.yml
.esbuildrc.toml
esbuild.config.json
esbuild.config.jsonc
esbuild.config.yaml
esbuild.config.yml
esbuild.config.toml
esbuild.config.js
esbuild.config.ts
esbuild.config.cjs
esbuild.config.mjs
CLI
npx cosmic-esbuild
npx cosmic-esbuild --config esbuild.config.ts
npx cosmic-esbuild --watch
License
This work is licensed under The MIT License.