ademenev
How to use an app as a dependency and reuse its config?
I have an application, lets call it A, that is in its own repo and has some configuration, and can run on its own. I want to create another application B that extends the functionality of A (A already provides some extension points). My idea is to use A as a dependency of B. The configuration of B must be inherited from A, so B can start it without having to redefine the config. Is it a good idea to just import A’s config into B’s config?
Most Liked
derek-zhou
I’d just copy the config file content because:
- Eventually, the config will diverge.
- If their is a large part of config that is static, maybe it is better to refactor it into code.
Last Post!
ademenev
So what’s the issue with this? Seems to work just fine
b/config/config.exs
import Config
import_config "../../a/config/config.exs"
b/mix.exs
defp deps do
[
{:a, path: "../a"}
]
end
If somewhere in A I am using for example Application.fetch_env!(:a, :x), then it works just fine when A is started both directly and as dependency of B. And B expectedly fails when I remove that import from its config
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









