# `mix compile`
[🔗](https://github.com/elixir-lang/elixir/blob/7ff272706afc522e74121493b7166719985cb099/lib/mix/lib/mix/tasks/compile.ex#L5)

The main entry point to compile source files.

It simply runs the compilers registered in your project and returns
a tuple with the compilation status and a list of diagnostics.

Before compiling code, it performs a series of checks to ensure all
dependencies are compiled and the project is up to date. Then the
code path of your Elixir system is pruned to only contain the dependencies
and applications that you have explicitly listed in your `mix.exs`.

## Configuration

  * `:compilers` - compilers to run, defaults to `Mix.compilers/0`,
    which are `[:erlang, :elixir, :app]`.

  * `:consolidate_protocols` - when `true`, runs protocol
    consolidation after compiling Elixir. The default value is `true`.

  * `:build_path` - the directory where build artifacts
    should be written to. This option is intended only for
    child apps within a larger umbrella application so that
    each child app can use the common `_build` directory of
    the parent umbrella. In a non-umbrella context, configuring
    this has undesirable side-effects (such as skipping some
    compiler checks) and should be avoided.

  * `:prune_code_paths` - prune code paths before compilation. When true
    (default), this prunes code paths of applications that are not listed
    in the project file with dependencies.  When false, this keeps the
    entirety of Erlang/OTP available when the project starts, including
    the paths set by the code loader from the `ERL_LIBS` environment as
    well as explicitly listed by providing `-pa` and `-pz` options
    to Erlang.

## Compilers

To see documentation for each specific compiler, you must
invoke `help` directly for the compiler command:

    $ mix help compile.elixir
    $ mix help compile.erlang

You can get a list of all compilers by running:

    $ mix compile --list

## Command line options

  * `--all-warnings` (`--no-all-warnings`) - prints all warnings, including previous compilations
    (default is true except on errors)
  * `--erl-config` - path to an Erlang term file that will be loaded as Mix config
  * `--force` - forces compilation. You can also specify `--force-#{compiler}` for each compiler
    invoked to force specifically that compiler to run (it requires the compiler to respect the
    `--force` option, which is advised)
  * `--list` - lists all enabled compilers
  * `--listeners` - starts Mix listeners (they are started by default,
    unless `--no-listeners` or `--no-deps-check` are given)
  * `--no-app-loading` - does not load .app resource file after compilation
  * `--no-archives-check` - skips checking of archives
  * `--no-compile` - does not actually compile, only loads code and perform checks
  * `--no-deps-check` - skips checking of dependencies
  * `--no-elixir-version-check` - does not check Elixir version
  * `--no-listeners` - does not start Mix listeners
  * `--no-optional-deps` - does not compile or load optional deps. Useful for testing
    if a library still successfully compiles without optional dependencies (which is the
    default case with dependencies). Passing this flag will force a full recompilation
  * `--no-prune-code-paths` - do not prune code paths before compilation, this keeps
    the entirety of Erlang/OTP available when the project starts
  * `--no-protocol-consolidation` - skips protocol consolidation
  * `--no-validate-compile-env` - does not validate the application compile environment
  * `--return-errors` - returns error status and diagnostics instead of exiting on error
  * `--warnings-as-errors` - exit with non-zero status if compilation has one or more
    warnings. Only concerns compilation warnings from the project, not its dependencies.

# `compilers`

> This function is deprecated. Use Mix.Task.Compiler.compilers/1 instead.

# `manifests`

> This function is deprecated. Use Mix.Task.Compiler.manifests/0 instead.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
