mix_gleam v0.4.0 mix gleam.compile

Compiles a single Gleam package.

This task wraps gleam compile-package and ensures that any Gleam code, in the main project and any dependencies, is compiled into Erlang, a task that should happen prior to Mix's compilation.

Examples:

# Compile Gleam to Erlang in the Mix project.
mix gleam.compile

# Compile Gleam to Erlang in a dependency.
mix gleam.compile gleam_stdlib

# Compile several dependencies.
mix gleam.compile gleam_http gleam_otp

# Force Gleam compilation.
mix gleam.compile gleam_plug --force 

# Prevent Gleam compilation.
mix deps.compile --no-gleam

Note that Gleam compilation can also be explicitly disabled for individual dependencies via mix.exs using, e.g.:

defp deps() do
  [
    ...
    {:package, "~> 0.1", gleam: false},
  ]
end

Gleam compilation will not be attempted in cases where it is thought to be unnecessary, unless the --force or --force-gleam flag or config option is passed; though even then, Gleam compilation will not occur where no .gleam files are located.

Include this task in your project's mix.exs with, e.g.:

def project do
  [
    # [...]
    aliases: MixGleam.add_aliases(),

    # or
    aliases: [
      "my.task": ["help"]
    ]
    |> MixGleam.add_aliases,

    # or
    aliases: ["compile.all": ["gleam.compile", "compile.all"]],
  ]
end