esbuild-config
Config files for esbuild.
Last updated 24 days ago by bpierre .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install esbuild-config 
SYNC missed versions from official npm registry.

esbuild-config

Config files for esbuild.

Why?

esbuild is an incredible tool, that is exclusively using command line parameters as a configuration syntax. Some people prefer configuration files, so I thought it could be a good idea to provide a solution for this. It is also for me a pretext to use Rust while learning it :)

Usage

The esbuild-config command outputs a list of parameters based on a esbuild.config.json file, that can get passed to esbuild directly:

esbuild $(esbuild-config)

It detects the presence of esbuild.config.json in the current directory, or the project root (using the presence of a package.json file). Any file can also get provided as a parameter:

esbuild $(esbuild-config ./my-conf.json)

Install

You have different options to install esbuild-config.

npm

Install globally with npm using the following command:

npm install --global esbuild-config

You can also add it to your project:

npm install --save-dev esbuild-config

Cargo

Install it with Cargo using the following command:

cargo install esbuild-config

Binaries

You can download the precompiled binaries from the release page.

From source

To clone the repository and build esbuild-config, run these commands (after having installed Rust):

git clone git@github.com:bpierre/esbuild-config.git
cd esbuild-config
cargo build --release

The compiled binary is at target/release/esbuild-config.

Syntax

esbuild-config doesn’t do any validation on the configuration values: it only converts JSON types into arguments that are compatible with the format esbuild uses for its arguments. This makes it independent from esbuild versions, assuming the format doesn’t change.

The only exception to this is the entry field, which gets converted into a list of file names (when an array is provided) or a single file name (when a string is provided).

This is how JSON types get converted:

{
  "entry": "./index.js",
  "outfile": "./bundle.js",
  "external": ["react", "react-dom"],
  "loader": { ".js": "jsx", ".png": "base64" },
  "minify": true
}

Output:

--outfile=./bundle.js --minify --external:react --external:react-dom --loader:.js=jsx --loader:.png=base64 ./index.js

Notice how the entry, ./index.js, has been moved to the end. esbuild-config also takes care of escaping the parameters as needed (e.g. by adding quotes).

Contribute

# Run the app
cargo run

# Run the tests
cargo test

# Generate the code coverage report
cargo tarpaulin -o Html

Special thanks

esbuild and its author obviously, not only for esbuild itself but also for its approach to install a platform-specific binary through npm, that esbuild-config is also using.

License

MIT

Current Tags

  • 0.2.0                                ...           latest (24 days ago)

4 Versions

  • 0.2.0                                ...           24 days ago
  • 0.1.0                                ...           2 months ago
  • 0.1.0-pre.1                                ...           2 months ago
  • 0.0.1-security                                ...           2 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 8
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |