Why does phx.gen.auth use only: [:dev] in deps?

In the readme for phx.gen.auth under Installation, it shows:

def deps do
  [
    {:phx_gen_auth, "~> 0.6", only: [:dev], runtime: false},
    ...
  ]
end

According to the mix deps documentation, the :only opt means

the dependency is made available only in the given environments, useful when declaring dev- or test-only dependencies; by default the dependency will be available in all environments. The value of this option can either be a single environment (like :dev ) or a list of environments (like [:dev, :test] )"

Why do we pass this option with phx.gen.auth? If we include phx.gen.auth according to these instructions and use it to create user accounts for the app, will the user authentication system still work after deployment?

Because the purpose of phx.gen.auth is only to generate some files/Elixir modules for you in your project. You likely (I hope) only need to generate those files in development phase.

It is not a library you then need at runtime. In fact, once you generated these modules, you could simply remove it from your deps/0.

6 Likes