{"id":13789972,"url":"https://github.com/bpierre/esbuild-config","last_synced_at":"2025-04-19T04:34:33.532Z","repository":{"id":57227294,"uuid":"291103635","full_name":"bpierre/esbuild-config","owner":"bpierre","description":"📜 Config files for esbuild.","archived":false,"fork":false,"pushed_at":"2022-09-22T18:07:35.000Z","size":41,"stargazers_count":77,"open_issues_count":2,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-11T16:05:40.080Z","etag":null,"topics":["esbuild","javascript","rust","typescript"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bpierre.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-28T17:14:25.000Z","updated_at":"2025-02-23T01:10:05.000Z","dependencies_parsed_at":"2022-08-25T12:21:58.558Z","dependency_job_id":null,"html_url":"https://github.com/bpierre/esbuild-config","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpierre%2Fesbuild-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpierre%2Fesbuild-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpierre%2Fesbuild-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpierre%2Fesbuild-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bpierre","download_url":"https://codeload.github.com/bpierre/esbuild-config/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248991709,"owners_count":21194925,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esbuild","javascript","rust","typescript"],"created_at":"2024-08-03T22:00:35.391Z","updated_at":"2025-04-19T04:34:33.517Z","avatar_url":"https://github.com/bpierre.png","language":"Rust","funding_links":[],"categories":["JavaScript Ecosystem"],"sub_categories":[],"readme":"# esbuild-config\n\nConfig files for [esbuild](https://github.com/evanw/esbuild).\n\n## Why?\n\nesbuild is an incredible tool, that is [using command line parameters](https://github.com/evanw/esbuild/issues/39) as a configuration syntax. This is fine, but some people might prefer using a configuration file.\n\nesbuild-config can transform a `esbuild.config.json` configuration file like this one:\n\n```json\n{\n  \"entry\": \"./index.js\",\n  \"outfile\": \"./bundle.js\",\n  \"external\": [\"react\", \"react-dom\"],\n  \"loader\": { \".js\": \"jsx\", \".png\": \"base64\" },\n  \"minify\": true\n}\n```\n\nInto a set of parameters for `esbuild`:\n\n```console\n--outfile=./bundle.js --minify --external:react --external:react-dom --loader:.js=jsx --loader:.png=base64 ./index.js\n```\n\nWhich means that `esbuild` can read a static configuration by running it this way:\n\n```console\nesbuild $(esbuild-config)\n```\n\n## Usage\n\nThe esbuild-config command outputs a list of parameters based on a `esbuild.config.json` file, that can get passed to esbuild directly:\n\n```console\nesbuild $(esbuild-config)\n```\n\nIt detects the presence of `esbuild.config.json` in the current directory or the project root (using the presence of a `package.json` file). The same configuration format can also get defined in the `package.json` file, using the `esbuild` field.json` file.\n\nA specific file path can also get passed as a parameter:\n\n```console\nesbuild $(esbuild-config ./my-conf.json)\n```\n\n## Syntax\n\nesbuild-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.\n\nThe 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).\n\nThis is how JSON types get converted:\n\n```json\n{\n  \"entry\": \"./index.js\",\n  \"outfile\": \"./bundle.js\",\n  \"external\": [\"react\", \"react-dom\"],\n  \"loader\": { \".js\": \"jsx\", \".png\": \"base64\" },\n  \"minify\": true\n}\n```\n\nOutput:\n\n```console\n--outfile=./bundle.js --minify --external:react --external:react-dom --loader:.js=jsx --loader:.png=base64 ./index.js\n```\n\nNotice 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).\n\n## Install\n\n### npm\n\nThe easiest way to install esbuild-config is through npm.\n\nInstall it globally using the following command:\n\n```console\nnpm install --global esbuild-config\n```\n\nOr add it to your project:\n\n```console\nnpm install --save-dev esbuild-config\n```\n\nSee below for [alternative installation methods](#other-installation-methods).\n\n### Binaries\n\nYou can download the precompiled binaries [from the release page](https://github.com/bpierre/esbuild-config/releases).\n\n### Cargo\n\nInstall it with [Cargo](https://github.com/rust-lang/cargo) using the following command:\n\n```console\ncargo install esbuild-config\n```\n\n### From source\n\nTo clone the repository and build esbuild-config, run these commands ([after having installed Rust](https://www.rust-lang.org/tools/install)):\n\n```console\ngit clone git@github.com:bpierre/esbuild-config.git\ncd esbuild-config\ncargo build --release\n```\n\nThe compiled binary is at `target/release/esbuild-config`.\n\n## Contribute\n\n```console\n# Run the app\ncargo run\n\n# Run the tests\ncargo test\n\n# Generate the code coverage report (install cargo-tarpaulin first)\ncargo tarpaulin -o Html\n```\n\n## FAQ\n\n### Doesn’t esbuild already support config files?\n\nThe recommended way to use a configuration file with esbuild is [through its Node.js API](https://github.com/evanw/esbuild/blob/1336fbcf9bcca2f2708f5f575770f13a8440bde3/docs/js-api.md), using a Node program as a configuration file:\n\n```js\nconst { build } = require('esbuild')\n\nbuild({\n  entryPoints: ['./index.js'],\n  outfile: './bundle.js',\n  external: ['react', 'react-dom'],\n  loader: { '.js': 'jsx', '.png': 'base64' },\n  minify: true,\n}).catch((error) =\u003e {\n  console.error(error)\n  process.exit(1)\n})\n```\n\nIf it works for you, you don’t need esbuild-config: the esbuild module already comes bundled with this JS API. esbuild-config provides an alternative way to configure esbuild. Instead of using the esbuild API through Node.js, it converts a [configuration file](#syntax) into command line parameters, that can be passed directly to the esbuild binary.\n\nThere are several reasons why you might want to use esbuild-config:\n\n- You prefer using JSON as a configuration language.\n- You prefer to have as much configuration as possible in the package.json.\n- You prefer to not launch Node at all in the process.\n\n## Special thanks\n\n[esbuild](https://github.com/evanw/esbuild) and [its author](https://github.com/evanw) obviously, not only for esbuild itself but also for its approach to [install a platform-specific binary through npm](https://github.com/evanw/esbuild/blob/1336fbcf9bcca2f2708f5f575770f13a8440bde3/lib/install.ts), that esbuild-config is also using.\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbpierre%2Fesbuild-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbpierre%2Fesbuild-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbpierre%2Fesbuild-config/lists"}