cosmic-esbuild
v0.7.2
Published
esbuild meets cosmiconfig, write your configs like you're used to
Downloads
1,219
Maintainers
Readme
cosmic-esbuild
esbuild meets cosmiconfig, write your configs like you're used to.
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-esbuildUsage
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 --watchFor 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 will likely need to define fine-grained permissions according to your needs. The important part is allowing to write to the
outdirdefined 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):
package.json.esbuildrc(see JSON or YAML).esbuildrc.json.esbuildrc.json5.esbuildrc.jsonc.esbuildrc.yaml.esbuildrc.yml.esbuildrc.toml.esbuildrc.js.esbuildrc.ts.esbuildrc.cjs.esbuildrc.mjs.esbuildrc.cts.esbuildrc.mts.esbuildrc.cson.config/esbuildrc(see JSON or YAML).config/esbuildrc.json.config/esbuildrc.json5.config/esbuildrc.jsonc.config/esbuildrc.yaml.config/esbuildrc.yml.config/esbuildrc.toml.config/esbuildrc.js.config/esbuildrc.ts.config/esbuildrc.cjs.config/esbuildrc.mjs.config/esbuildrc.cts.config/esbuildrc.mts.config/esbuildrc.csonesbuild.config.jsonesbuild.config.json5esbuild.config.jsoncesbuild.config.yamlesbuild.config.ymlesbuild.config.tomlesbuild.config.jsesbuild.config.tsesbuild.config.cjsesbuild.config.mjsesbuild.config.ctsesbuild.config.mtsesbuild.config.cson
Related
If this project is not for you, maybe these alternatives suit you better:
License
This work is licensed under The MIT License.
