Setting Up Development-Only Logic in Elixir Projects

249
clicks
Setting Up Development-Only Logic in Elixir Projects

Source: danschultzer.com

Type: Post

Dan Schultzer outlines a strategy for Elixir developers to manage development-specific logic separate from production code by using a special _dev directory combined with Config settings. He uses a Phoenix project as an example but mentions that this pattern can be applied to any Elixir project. Dan's approach involves updating the elixirc_paths in the mix.exs file to include the _dev files in dev and test environments and adjusting the .formatter.exs for the mix format to apply to the new directory. He also provides an example of a seed tool setup to demonstrate the use of the _dev directory for development-only modules and tools. The method helps in creating a clean separation of development and production concerns, avoiding the use of Mix.env() == :dev checks sprinkled throughout the codebase.

© HashMerge 2024