Skip to content

idleberg/cosmic-esbuild

Repository files navigation

cosmic-esbuild

esbuild meets cosmiconfig, write your configs like you're used to.

License Version: npm Version: jsr GitHub branch check runs

Description

This package allows you to 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

CLI

Note

The CLI should primarily be used with configuration files. However, some of the basic esbuild options can be passed as command-line arguments. While it might make sense to sometimes override the configuration via flag, it's not a goal of this project to replicate esbuild's CLI functionality.

Node.js

# Build, auto-load config
npx cosmic-esbuild

# Build, specify config
npx cosmic-esbuild --config esbuild.config.ts

# Watch
npx cosmic-esbuild --watch

For a full list of command-line arguments, run npx cosmic-build --help.

Bun

All of the Node.js examples are valid as long as you substitute npx with bunx.

Deno

Using Deno, you probably want to create tasks in your deno.json file:

Warning

The following example is simplied for brevity. You likely want to define fine-grained permissions according to your needs. The important part is allowing to write to the outdir defined in your esbuild config.

{
	"tasks": {
		"build": "deno run --allow-write='dist' jsr:@idleberg/cosmic-esbuild",
		"dev": "deno run --allow-write='dist' jsr:@idleberg/cosmic-esbuild --watch"
	}
}

File Formats

You can write your configuration files in a number of formats. See the following examples (sorted by precedence):

Example Configurations

Related

If this project is not for you, maybe these alternatives suit you better:

License

This work is licensed under The MIT License.

About

esbuild meets cosmiconfig, write your configs like you're used to

Topics

Resources

Stars

Watchers

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages