{"id":13491640,"url":"https://github.com/phoenixframework/esbuild","last_synced_at":"2025-03-28T08:33:21.877Z","repository":{"id":39678852,"uuid":"386765532","full_name":"phoenixframework/esbuild","owner":"phoenixframework","description":"An installer for esbuild","archived":false,"fork":false,"pushed_at":"2025-02-10T15:31:54.000Z","size":109,"stargazers_count":272,"open_issues_count":1,"forks_count":40,"subscribers_count":18,"default_branch":"main","last_synced_at":"2025-03-24T19:07:21.898Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/phoenixframework.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-16T21:13:34.000Z","updated_at":"2025-02-26T14:50:16.000Z","dependencies_parsed_at":"2023-01-27T22:30:39.127Z","dependency_job_id":"bb8eed28-d39e-42f3-b80d-c7950fa5985b","html_url":"https://github.com/phoenixframework/esbuild","commit_stats":{"total_commits":97,"total_committers":24,"mean_commits":4.041666666666667,"dds":"0.48453608247422686","last_synced_commit":"ab489bec79985b774733ca237016b4e1690f46bc"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phoenixframework%2Fesbuild","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phoenixframework%2Fesbuild/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phoenixframework%2Fesbuild/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phoenixframework%2Fesbuild/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phoenixframework","download_url":"https://codeload.github.com/phoenixframework/esbuild/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245996863,"owners_count":20707345,"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":[],"created_at":"2024-07-31T19:00:58.923Z","updated_at":"2025-03-28T08:33:21.580Z","avatar_url":"https://github.com/phoenixframework.png","language":"Elixir","funding_links":[],"categories":["Elixir"],"sub_categories":[],"readme":"# Esbuild\n\n[![CI](https://github.com/phoenixframework/esbuild/actions/workflows/main.yml/badge.svg)](https://github.com/phoenixframework/esbuild/actions/workflows/main.yml)\n\nMix tasks for installing and invoking [esbuild](https://esbuild.github.io/).\n\n## Installation\n\nIf you are going to build assets in production, then you add\n`esbuild` as dependency on all environments but only start it\nin dev:\n\n```elixir\ndef deps do\n  [\n    {:esbuild, \"~\u003e 0.7\", runtime: Mix.env() == :dev}\n  ]\nend\n```\n\nHowever, if your assets are precompiled during development,\nthen it only needs to be a dev dependency:\n\n```elixir\ndef deps do\n  [\n    {:esbuild, \"~\u003e 0.7\", only: :dev}\n  ]\nend\n```\n\nOnce installed, change your `config/config.exs` and [pick a version\nfor the esbuild CLI](https://github.com/evanw/esbuild/releases) of your choice:\n\n```elixir\nconfig :esbuild, version: \"0.18.6\"\n```\n\nNow you can install esbuild by running:\n\n```bash\n$ mix esbuild.install\n```\n\nAnd invoke esbuild with:\n\n```bash\n$ mix esbuild default assets/js/app.js --bundle --minify --target=es2016 --outdir=priv/static/assets/\n```\n\nThe executable is kept at `_build/esbuild-TARGET`.\nWhere `TARGET` is your system target architecture.\n\n## Profiles\n\nThe first argument to `esbuild` is the execution profile.\nYou can define multiple execution profiles with the current\ndirectory, the OS environment, and default arguments to the\n`esbuild` task:\n\n```elixir\nconfig :esbuild,\n  version: \"0.18.6\",\n  default: [\n    args: ~w(js/app.js),\n    cd: Path.expand(\"../assets\", __DIR__)\n  ]\n```\n\nWhen `mix esbuild default` is invoked, the task arguments will be appended\nto the ones configured above. Note profiles must be configured in your\n`config/config.exs`, as `esbuild` runs without starting your application\n(and therefore it won't pick settings in `config/runtime.exs`).\n\n## Adding to Phoenix\n\nTo add `esbuild` to an application using Phoenix, you need only four steps.  Installation requires that Phoenix watchers can accept module-function-args tuples which is not built into Phoenix 1.5.9.\n\nFirst add it as a dependency in your `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:phoenix, github: \"phoenixframework/phoenix\", branch: \"v1.5\", override: true},\n    {:esbuild, \"~\u003e 0.7\", runtime: Mix.env() == :dev}\n  ]\nend\n```\n\nNow let's change `config/config.exs` to configure `esbuild` to use\n`assets/js/app.js` as an entry point and write to `priv/static/assets`:\n\n```elixir\nconfig :esbuild,\n  version: \"0.18.6\",\n  default: [\n    args: ~w(js/app.js --bundle --target=es2016 --outdir=../priv/static/assets),\n    cd: Path.expand(\"../assets\", __DIR__),\n    env: %{\"NODE_PATH\" =\u003e Path.expand(\"../deps\", __DIR__)}\n  ]\n```\n\n\u003e Make sure the \"assets\" directory from priv/static is listed in the\n\u003e :only option for Plug.Static in your lib/my_app_web/endpoint.ex\n\nFor development, we want to enable watch mode. So find the `watchers`\nconfiguration in your `config/dev.exs` and add:\n\n```elixir\n  esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]}\n```\n\nNote we are inlining source maps and enabling the file system watcher.\n\nFinally, back in your `mix.exs`, make sure you have a `assets.deploy`\nalias for deployments, which will also use the `--minify` option:\n\n```elixir\n\"assets.deploy\": [\"esbuild default --minify\", \"phx.digest\"]\n```\n\n## Third-party JS packages\n\nIf you have JavaScript dependencies, you have two options\nto add them to your application:\n\n  1. Vendor those dependencies inside your project and\n     import them in your \"assets/js/app.js\" using a relative\n     path:\n\n         import topbar from \"../vendor/topbar\"\n\n  2. Call `npm install topbar --save` inside your assets\n     directory and `esbuild` will be able to automatically\n     pick them up:\n\n         import topbar from \"topbar\"\n\n## CSS\n\n`esbuild` has basic support for CSS. If you import a css file at the\ntop of your main `.js` file, `esbuild` will also bundle it, and write\nit to the same directory as your `app.js`:\n\n```js\nimport \"../css/app.css\"\n```\n\nHowever, if you want to use a CSS framework, you will need to use a separate tool.\nHere are some options to do so:\n\n  * Use [standalone Tailwind](https://github.com/phoenixframework/tailwind) or\n    [standalone SASS](https://github.com/CargoSense/dart_sass). Both similar to\n    `esbuild`.\n\n  * You can use `esbuild` plugins (requires `npm`). See [Phoenix' official\n    guide on using them](https://hexdocs.pm/phoenix/asset_management.html).\n\n## License\n\nCopyright (c) 2021 Wojtek Mach, José Valim.\n\nesbuild source code is licensed under the [MIT License](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphoenixframework%2Fesbuild","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphoenixframework%2Fesbuild","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphoenixframework%2Fesbuild/lists"}