View Source Esbuild (esbuild v0.8.1)

Esbuild is an installer and runner for esbuild.

Profiles

You can define multiple esbuild profiles. By default, there is a profile called :default which you can configure its args, current directory and environment:

config :esbuild,
  version: "0.17.11",
  default: [
    args: ~w(js/app.js --bundle --target=es2016 --outdir=../priv/static/assets),
    cd: Path.expand("../assets", __DIR__),
    env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
  ]

Esbuild configuration

There are two global configurations for the esbuild application:

  • :version - the expected esbuild version

  • :cacerts_path - the directory to find certificates for https connections

  • :path - the path to find the esbuild executable at. By default, it is automatically downloaded and placed inside the _build directory of your current app

Overriding the :path is not recommended, as we will automatically download and manage esbuild for you. But in case you can't download it (for example, the npm registry is behind a proxy), you may want to set the :path to a configurable system location.

For instance, you can install esbuild globally with npm:

$ npm install -g esbuild

On Unix, the executable will be at:

NPM_ROOT/esbuild/node_modules/@esbuild/TARGET/bin/esbuild

On Windows, it will be at:

NPM_ROOT/esbuild/node_modules/@esbuild/win32-x(32|64)/esbuild.exe

Where NPM_ROOT is the result of npm root -g and TARGET is your system target architecture.

Once you find the location of the executable, you can store it in a MIX_ESBUILD_PATH environment variable, which you can then read in your configuration file:

config :esbuild, path: System.get_env("MIX_ESBUILD_PATH")

Summary

Functions

Returns the path to the executable.

Returns the version of the esbuild executable.

Returns the configuration for the given profile.

Returns the configured esbuild version.

Installs esbuild with configured_version/0.

Installs, if not available, and then runs esbuild.

Runs the given command with args.

Functions

Returns the path to the executable.

The executable may not be available if it was not yet installed.

Returns the version of the esbuild executable.

Returns {:ok, version_string} on success or :error when the executable is not available.

Returns the configuration for the given profile.

Returns nil if the profile does not exist.

Returns the configured esbuild version.

Installs esbuild with configured_version/0.

If invoked concurrently, this task will perform concurrent installs.

Link to this function

install_and_run(profile, args)

View Source

Installs, if not available, and then runs esbuild.

This task may be invoked concurrently and it will avoid concurrent installs.

Returns the same as run/2.

Link to this function

run(profile, extra_args)

View Source

Runs the given command with args.

The given args will be appended to the configured args. The task output will be streamed directly to stdio. It returns the status of the underlying call.