Esbuild (esbuild v0.4.0) View Source

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.14.0",
  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

  • :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-windows-(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")

Link to this section 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.

Link to this section 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.

Link to this function

install_and_run(profile, args)

View Source

Installs, if not available, and then runs esbuild.

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.